@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,480 @@
1
+ // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
+ // src/three-openvdb/frame/webgpu/FrameRenderer.js L191–246 (the settings; now the core's), L431–481 (render: the
3
+ // first proxy of a render draws the frame, override passes draw nothing), L1476–1716 (visitLight: the scene's lights
4
+ // in the camera's layers).
5
+ // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
6
+ // Changes (K6.8): the TSL passes are gone; every frame is the core frame renderer (`vdbCreateFrameRenderer`, compute on
7
+ // three's device), recorded into its own encoder and submitted before three's frame. Divergences: DIVERGES.md (K3.1,
8
+ // K3.3, K6 rows).
9
+ /**
10
+ * The froxel renderer of `./three` (K6.8, design §6): a thin adapter over the core frame renderer. One
11
+ * core `VDBFrameRenderer` per three renderer device; in the first `VDBFrameVolume` proxy's `onBeforeRender` of a render (or
12
+ * a volume shadow receiver's / the emission light's `updateBefore`, whichever comes first) it collects the volumes in the
13
+ * camera's layers, converts the scene's lights (shadow cameras → volume shadow requests, three's shadow maps →
14
+ * occluders), passes `scene.environment`, records `core.update()` into its own encoder and submits; three's frame
15
+ * submits after it. Every proxy then draws the composite material over three's scene depth and colour.
16
+ */
17
+ import * as THREE from "three";
18
+ import { vdbFrameMlpFromNeural } from "../../tools/frame/mlp.js";
19
+ import { vdbFrameNeuralWeights } from "../../tools/frame/neural-weights.js";
20
+ import { vdbFrameDefaultSettings } from "../../core/frame/settings.js";
21
+ import { vdbCreateFrameRenderer } from "../../core/frame/renderer.js";
22
+ import { vdbSparseSource as vdbCoreSparseSource } from "../../core/source/sparse.js";
23
+ import { vdbDenseSource } from "../../core/source/dense.js";
24
+ import { getDevice } from "../device.js";
25
+ import { vdbFrameRenderId } from "./three-internals.js";
26
+ import { VDBCoreTextureBinding, vdbCoreTextureSelfTest } from "./core-textures.js";
27
+ import { VDBFrameCoreIntegrateMaterial } from "./core-integrate-material.js";
28
+ import { VDBCoreOccluders } from "./core-occluders.js";
29
+ import { VDBCoreEnvironment } from "./core-environment.js";
30
+ import { VDBFrameVolumeShadowReceivers } from "./volume-shadows.js";
31
+ import { getFrameAngstromExponent } from "./spectrum.js";
32
+ /** Our trained network (K6.N, D36) as the core MLP (the default `mlp`; one object, so the core uploads it once). */
33
+ const DEFAULT_MLP = vdbFrameMlpFromNeural(vdbFrameNeuralWeights);
34
+ /** Instanced, so a proxy skips its draw with `instanceCount = 0` (three draws no instances). A quad the composite places. */
35
+ const proxyQuad = new THREE.Float32BufferAttribute([-1, -1, 0, 1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, 1, 0], 3);
36
+ /** His `FrameRenderer`, on the core: one instance can serve many volumes and cameras. */
37
+ export class VDBFrameRenderer {
38
+ /**
39
+ * The settings (the core's `VDBFrameSettings`: his names and v0.26 defaults plus the K6 fields); live, read at the
40
+ * next render and shared by every volume this renderer draws.
41
+ */
42
+ settings = vdbFrameDefaultSettings();
43
+ /**
44
+ * EXPERIMENTAL: the network of `multipleScattering` `'mlp'` / `'neural'` as `VDBFrameMlp` data (layer shapes,
45
+ * activations, weights; default: mjurczyk's trained weights). Assign another network of that form (no rebuild), or
46
+ * null to run those modes as 1D diffusion (warned).
47
+ */
48
+ mlp = DEFAULT_MLP;
49
+ /** Timing and debug hooks around each core update ({@link VDBFramePassHook}). */
50
+ passHook = null;
51
+ /**
52
+ * Whether the volumes are drawn into the froxels at the next render (default true). False keeps the last froxels
53
+ * (the composite still draws them; volume shadow maps and probes still update): `update(…, { froxels: false })`.
54
+ */
55
+ froxels = true;
56
+ #core = null;
57
+ #device = null;
58
+ #material = null;
59
+ #prefix = new VDBCoreTextureBinding();
60
+ /** K6.4: the stand-in of the spectral alpha prefix (`outputs.froxels.integratedAlpha`). */
61
+ #alphaPrefix = new VDBCoreTextureBinding();
62
+ #denseSources = new WeakMap();
63
+ #sparseSources = new Map();
64
+ #sparseSlots = new WeakMap();
65
+ /** The three source's stats object each core slot last took (a new object: `refreshStats()` ran). */
66
+ #slotStats = new WeakMap();
67
+ #volumes = new Map();
68
+ #frameId = 0;
69
+ #frameKey = null;
70
+ #cachedFrame = -1;
71
+ #cachedCamera = null;
72
+ #rendererWarned = false;
73
+ /** K6.5b: three's shadow maps as the core's occluder maps. */
74
+ #occluders = new VDBCoreOccluders();
75
+ /** K6.2b: `scene.environment` as the core's environment input. */
76
+ #environment = new VDBCoreEnvironment();
77
+ /** @internal K6.5: volume shadows on meshes: the shadow filter on each shadow light, reading the core's maps. */
78
+ volumeShadows = new VDBFrameVolumeShadowReceivers(this);
79
+ /** The core frame renderer (made at the first render, per device; null before). Read its `outputs`; set nothing on it. */
80
+ get core() {
81
+ return this.#core;
82
+ }
83
+ /** Redraws and skips of the core's signature-cached passes ('frame' lighting) and volume shadow pieces (zeros before the first render). */
84
+ get redrawStats() {
85
+ return this.#core?.redrawStats ?? { shadowDensity: { drawn: 0, skipped: 0 }, transmittance: { drawn: 0, skipped: 0 }, environmentGrid: { drawn: 0, skipped: 0 }, volumeShadows: { drawn: 0, waiting: 0 } };
86
+ }
87
+ /** The composite material every volume proxy draws (one per renderer). */
88
+ proxyMaterial() {
89
+ this.#material ??= new VDBFrameCoreIntegrateMaterial();
90
+ return this.#material;
91
+ }
92
+ /** A quad geometry for a volume proxy; the composite places it over the froxel area. */
93
+ createProxyGeometry() {
94
+ const geometry = new THREE.InstancedBufferGeometry();
95
+ geometry.instanceCount = 1;
96
+ geometry.setAttribute("position", proxyQuad);
97
+ return geometry;
98
+ }
99
+ /**
100
+ * Called by each volume proxy before it draws: the first proxy of a render runs the core update (once per render,
101
+ * camera and scene); every proxy then composites the froxels. Override passes (depth, normals) draw nothing.
102
+ */
103
+ render(renderer, scene, camera, proxy) {
104
+ if (!renderer.isWebGPURenderer) {
105
+ if (!this.#rendererWarned) {
106
+ console.error("VDBFrameVolume: needs WebGPURenderer (three/webgpu).");
107
+ this.#rendererWarned = true;
108
+ }
109
+ return;
110
+ }
111
+ if (scene.overrideMaterial) {
112
+ proxy.geometry.instanceCount = 0;
113
+ return;
114
+ }
115
+ const frame = renderer.info.render.calls;
116
+ if (frame === this.#cachedFrame && camera === this.#cachedCamera) {
117
+ proxy.geometry.instanceCount = 0;
118
+ return;
119
+ }
120
+ const material = this.proxyMaterial();
121
+ // NOTE three draws the material it chose before onBeforeRender: a swapped proxy draws the composite from the next frame
122
+ if (proxy.material !== material)
123
+ proxy.material = material;
124
+ const u = this.coreFrame(renderer, scene, camera);
125
+ if (u?.recorded && u.outputs.froxels) {
126
+ if (this.#prefix.set(u.outputs.froxels.integrated))
127
+ material.prefix.value = this.#prefix.texture;
128
+ // K6.4: spectral media composite with the alpha prefix (their own blend over three's viewport texture)
129
+ const alpha = u.outputs.froxels.integratedAlpha;
130
+ if (alpha && this.#alphaPrefix.set(alpha))
131
+ material.alphaPrefix.value = this.#alphaPrefix.texture;
132
+ material.setSpectral(!!alpha);
133
+ material.setLayout(u.outputs.froxels.layout, camera);
134
+ material.setSrgbBlending(this.settings.srgbBlending && renderer.outputColorSpace === THREE.SRGBColorSpace, renderer.toneMapping === THREE.NoToneMapping);
135
+ }
136
+ this.#cachedFrame = renderer.info.render.calls;
137
+ this.#cachedCamera = camera;
138
+ proxy.geometry.instanceCount = u?.recorded ? 1 : 0;
139
+ }
140
+ /**
141
+ * The core update of one render, recorded into its own encoder and submitted (three's frame submits after it, so queue
142
+ * order is right). It runs once per render id, camera and scene; the first caller runs it: a volume shadow receiver's
143
+ * or the emission light's `updateBefore` (before any receiver of the render draws, his order), else the first volume
144
+ * proxy. The volume shadow maps and the emission probes are drawn here.
145
+ */
146
+ coreFrame(renderer, scene, camera) {
147
+ if (!renderer.isWebGPURenderer)
148
+ return null;
149
+ const renderId = vdbFrameRenderId(renderer);
150
+ const key = this.#frameKey;
151
+ if (key && key.renderId === renderId && key.camera === camera && key.scene === scene)
152
+ return key.result;
153
+ const device = getDevice(renderer);
154
+ if (!this.#core || this.#device !== device) {
155
+ vdbCoreTextureSelfTest(renderer, device);
156
+ this.#core?.dispose();
157
+ this.#core = vdbCreateFrameRenderer(device, { label: "vdb three frame" });
158
+ this.#device = device;
159
+ this.#denseSources = new WeakMap();
160
+ this.#volumes = new Map();
161
+ this.#disposeSparse();
162
+ }
163
+ const core = this.#core;
164
+ Object.assign(core.settings, this.settings);
165
+ core.mlp = this.mlp;
166
+ // K6.5: the volume shadow filter on each shadow light (receivers build with it from the next render)
167
+ this.volumeShadows.update(renderer, scene);
168
+ const seen = new Set();
169
+ scene.traverseVisible((object) => {
170
+ const frameVolume = object;
171
+ if (!frameVolume.isVDBFrameVolume || frameVolume.frameRenderer !== this || !frameVolume.proxy.layers.test(camera.layers))
172
+ return;
173
+ frameVolume.syncSource();
174
+ const handle = this.#volumeOf(frameVolume, device);
175
+ frameVolume.boxMatrixWorld.multiplyMatrices(frameVolume.matrixWorld, frameVolume.boxMatrix);
176
+ this.#setParams(handle.params, frameVolume, frameVolume.boxMatrixWorld);
177
+ handle.visible = true;
178
+ // his collector: every volume in the camera's layers casts into the shadow grid, also out of view
179
+ handle.castsShadow = true;
180
+ seen.add(handle);
181
+ });
182
+ for (const [frameVolume, handle] of this.#volumes) {
183
+ if (seen.has(handle))
184
+ continue;
185
+ // a volume that is hidden (or out of the camera's layers) neither draws nor casts (Traps: the core casts invisible volumes)
186
+ handle.visible = false;
187
+ handle.castsShadow = false;
188
+ if (!frameVolume.parent) {
189
+ handle.remove();
190
+ this.#volumes.delete(frameVolume);
191
+ }
192
+ }
193
+ const cam = camera;
194
+ const buffer = renderer.getDrawingBufferSize(new THREE.Vector2());
195
+ const canvas = renderer.getSize(new THREE.Vector2());
196
+ const { lights, emissionLight, shadowLights } = this.#lights(scene, camera);
197
+ // K6.5b: three draws its pending shadow maps now (before this update's submit), so the occluders are this frame's
198
+ const occluders = this.settings.occlusion ? this.#occluders.input(renderer, scene, camera, shadowLights) : [];
199
+ const hook = this.passHook;
200
+ hook?.begin?.();
201
+ const encoder = device.createCommandEncoder({ label: "vdb three frame" });
202
+ const u = core.update(encoder, {
203
+ frameId: this.#frameId++,
204
+ camera: {
205
+ view: camera.matrixWorldInverse.elements,
206
+ projection: camera.projectionMatrix.elements,
207
+ near: cam.near,
208
+ far: cam.far,
209
+ orthographic: !!cam.isOrthographicCamera,
210
+ reversedDepth: !!renderer.reversedDepthBuffer,
211
+ id: camera.id,
212
+ },
213
+ viewport: { drawingBuffer: [buffer.x, buffer.y], canvas: [canvas.x, canvas.y] },
214
+ lights,
215
+ emissionLight,
216
+ environment: this.#environment.input(renderer, scene),
217
+ occluders,
218
+ }, { froxels: this.froxels, ...(hook?.timestampWrites ? { timestampWrites: hook.timestampWrites } : {}) });
219
+ device.queue.submit([encoder.finish()]);
220
+ // K6.5: the receivers read the maps with the state they were drawn with (copied to their uniforms now, before they draw)
221
+ this.volumeShadows.sync(u.outputs.volumeShadows, core.redrawStats.volumeShadows);
222
+ hook?.end?.(u);
223
+ this.#frameKey = { renderId, camera, scene, result: u };
224
+ return u;
225
+ }
226
+ /** The core volume of a frame volume: its dense source uploaded once on the core side, or a slot of a sparse source. */
227
+ #volumeOf(frameVolume, device) {
228
+ if (frameVolume.source.kind !== "dense")
229
+ return this.#sparseVolumeOf(frameVolume);
230
+ const three = frameVolume.source;
231
+ let source = this.#denseSources.get(three);
232
+ if (!source) {
233
+ source = vdbDenseSource(device, three.volume, { label: "vdb three dense" });
234
+ this.#denseSources.set(three, source);
235
+ }
236
+ else if (source.volume !== three.volume) {
237
+ source.replace(three.volume);
238
+ }
239
+ let handle = this.#volumes.get(frameVolume);
240
+ if (handle && handle.slot.source !== source) {
241
+ handle.remove();
242
+ handle = undefined;
243
+ }
244
+ if (!handle) {
245
+ handle = this.#core.addVolume(source);
246
+ this.#volumes.set(frameVolume, handle);
247
+ }
248
+ return handle;
249
+ }
250
+ /**
251
+ * K6.1d: the core volume of a frame volume on a sparse source: one core `vdbSparseSource` per pool and source options
252
+ * (its pyramids are the core's own), one slot per three source with the same grids, boxes and stats. K6.8a: the three
253
+ * source is a handle; its TSL half (and its own pyramid) is never made here.
254
+ */
255
+ #sparseVolumeOf(frameVolume) {
256
+ const three = frameVolume.source;
257
+ const pool = three.grids.pool;
258
+ const types = three.grids.options.types;
259
+ const options = {
260
+ lod: three.lod,
261
+ normalize: three.normalize,
262
+ followImage: three.followImage,
263
+ fastTrilinear: three.fastTrilinear,
264
+ cacheAccessor: three.cacheAccessor,
265
+ ...(three.pyramidOptions?.pyramidMax !== undefined ? { pyramidMax: three.pyramidOptions.pyramidMax } : {}),
266
+ ...(types ? { types } : {}),
267
+ // K3.2f (internal): the brick cache; absent when off, so the key (and the source) is the one without it
268
+ ...(three.brickCache && three.brickCache !== "off" ? { brickCache: three.brickCache, ...three.brickOptions } : {}),
269
+ };
270
+ const key = JSON.stringify(options);
271
+ let byKey = this.#sparseSources.get(pool);
272
+ if (!byKey)
273
+ this.#sparseSources.set(pool, (byKey = new Map()));
274
+ let source = byKey.get(key);
275
+ if (!source) {
276
+ source = vdbCoreSparseSource(pool, { ...options, label: "vdb three sparse" });
277
+ byKey.set(key, source);
278
+ }
279
+ let handle = this.#volumes.get(frameVolume);
280
+ let slot = this.#sparseSlots.get(three);
281
+ if (!slot || slot.source !== source || slot.removed) {
282
+ slot?.remove();
283
+ const aux = three.auxBoxes ?? { mask: null, albedo: null, emission: null };
284
+ const auxIndexBoxes = Object.fromEntries(Object.entries(aux).filter(([, b]) => b));
285
+ slot = source.volume(three.ids, three.followImage ? { stats: three.stats } : { indexBox: three.indexBox, auxIndexBoxes, stats: three.stats });
286
+ this.#sparseSlots.set(three, slot);
287
+ this.#slotStats.set(slot, three.stats);
288
+ }
289
+ else if (this.#slotStats.get(slot) !== three.stats) {
290
+ // the three source re-read its stats (`refreshStats()` after a replace): the core slot takes them now, instead of
291
+ // a frame or two later from its own readback of the same image (a coarse-first swap's first full frame, G16a)
292
+ slot.stats = { ...three.stats };
293
+ this.#slotStats.set(slot, three.stats);
294
+ }
295
+ if (handle && handle.slot !== slot) {
296
+ handle.remove();
297
+ handle = undefined;
298
+ }
299
+ if (!handle) {
300
+ handle = this.#core.addVolume(slot);
301
+ this.#volumes.set(frameVolume, handle);
302
+ }
303
+ return handle;
304
+ }
305
+ /** Frees the sparse sources (their slots and pyramids); the pools are the host's. */
306
+ #disposeSparse() {
307
+ for (const byKey of this.#sparseSources.values())
308
+ for (const s of byKey.values())
309
+ s.dispose();
310
+ this.#sparseSources = new Map();
311
+ this.#sparseSlots = new WeakMap();
312
+ }
313
+ /** A frame volume's props as the core's params. */
314
+ #setParams(p, v, matrixWorld) {
315
+ const wrap = v.wrap3D === THREE.RepeatWrapping ? "repeat" : v.wrap3D === THREE.MirroredRepeatWrapping ? "mirror" : "clamp";
316
+ const params = {
317
+ matrixWorld: matrixWorld.elements.slice(),
318
+ baseColor: [v.baseColor.r, v.baseColor.g, v.baseColor.b],
319
+ scatterColor: [v.scatterColor.r, v.scatterColor.g, v.scatterColor.b],
320
+ extinction: v.extinction,
321
+ extinctionScale: [v.extinctionScale.x, v.extinctionScale.y, v.extinctionScale.z],
322
+ // K6.4: a preset name ('smoke', 'air', …) or a number (his getFrameAngstromExponent)
323
+ angstromExponent: getFrameAngstromExponent(v.angstromExponent),
324
+ densityScale: v.densityScale,
325
+ normalizeDensity: v.normalizeDensity,
326
+ densityMean: v.densityMean,
327
+ densityCutoff: v.densityCutoff,
328
+ absorbance: v.absorbance,
329
+ opacity: v.opacity,
330
+ emissiveIntensity: v.emissiveIntensity,
331
+ temperatureRange: [v.temperatureRange.x, v.temperatureRange.y],
332
+ offset3D: [v.offset3D.x, v.offset3D.y, v.offset3D.z],
333
+ wrap3D: wrap,
334
+ lights: v.lights,
335
+ shadowSteps: v.shadowSteps,
336
+ mipmaps: v.mipmaps,
337
+ hdda: v.hdda,
338
+ phase: v.phase,
339
+ phaseG: v.phaseG,
340
+ phaseBackG: v.phaseBackG,
341
+ phaseBackWeight: v.phaseBackWeight,
342
+ phaseGExponent: v.phaseGExponent,
343
+ emissionColor: this.#emissionColor(v),
344
+ };
345
+ Object.assign(p, params);
346
+ }
347
+ /** K6.5: the volume's emission colour as core data ('white' when unset). */
348
+ #emissionColor(v) {
349
+ return v.emissionColor ?? "white";
350
+ }
351
+ /**
352
+ * The scene's lights in the camera's layers as core lights (his visitLight). K6.5: a shadow light with the volume
353
+ * shadow filter on it asks for a volume shadow map (spot: the light's own shadow camera, so both maps share one texel
354
+ * grid; point: its cube near / far; directional: cascades fitted by the core); a `VDBFrameEmissionLight` gives the
355
+ * emission probe settings.
356
+ */
357
+ #lights(scene, camera) {
358
+ const out = [];
359
+ // K6.5b: the directional, spot and point lights passed (their shadow maps are the occluders)
360
+ const shadowLights = [];
361
+ let emissionLight = null;
362
+ const position = new THREE.Vector3();
363
+ const target = new THREE.Vector3();
364
+ const size = this.volumeShadows.getMapSize();
365
+ scene.traverseVisible((object) => {
366
+ const light = object;
367
+ if (!light.isLight || !light.layers.test(camera.layers))
368
+ return;
369
+ if (light.isVDBFrameEmissionLight) {
370
+ if (!emissionLight) {
371
+ const e = light;
372
+ emissionLight = { resolution: e.resolution, range: e.range, cascades: e.cascades, distance: e.distance, steps: Math.max(1, Math.round(e.steps)) };
373
+ }
374
+ return;
375
+ }
376
+ const i = light.intensity;
377
+ const color = [light.color.r * i, light.color.g * i, light.color.b * i];
378
+ position.setFromMatrixPosition(light.matrixWorld);
379
+ const id = light.id;
380
+ // K6.5: a map for each light the volume shadow filter is on (volumeShadows.update installed it)
381
+ let shadow;
382
+ if (this.settings.castShadows && light.castShadow && this.volumeShadows.entries.has(light)) {
383
+ if (light.isSpotLight) {
384
+ light.shadow.updateMatrices(light);
385
+ const c = light.shadow.camera;
386
+ shadow = { size, view: { viewProjection: new THREE.Matrix4().multiplyMatrices(c.projectionMatrix, c.matrixWorldInverse).elements, near: c.near, far: c.far, orthographic: false } };
387
+ }
388
+ else if (light.isPointLight) {
389
+ const c = light.shadow.camera;
390
+ shadow = { size, view: { near: c.near, far: light.distance || c.far } };
391
+ }
392
+ else if (light.isDirectionalLight)
393
+ shadow = { size, view: "fit" };
394
+ }
395
+ if ((light.isDirectionalLight || light.isSpotLight || light.isPointLight) && light.castShadow)
396
+ shadowLights.push(light);
397
+ if (light.isAmbientLight)
398
+ out.push({ id, kind: "ambient", color });
399
+ else if (light.isHemisphereLight) {
400
+ const g = light.groundColor;
401
+ const up = position.lengthSq() > 0 ? position.clone().normalize() : new THREE.Vector3(0, 1, 0);
402
+ out.push({ id, kind: "hemisphere", sky: color, ground: [g.r * i, g.g * i, g.b * i], up: [up.x, up.y, up.z] });
403
+ }
404
+ else if (light.isLightProbe) {
405
+ out.push({ id, kind: "probe", sh: light.sh.coefficients.flatMap((c) => [c.x * i, c.y * i, c.z * i]) });
406
+ }
407
+ else if (light.isDirectionalLight) {
408
+ target.setFromMatrixPosition(light.target.matrixWorld).sub(position).normalize();
409
+ out.push({ id, kind: "directional", direction: [target.x, target.y, target.z], color, ...(shadow ? { shadow } : {}) });
410
+ }
411
+ else if (light.isSpotLight) {
412
+ target.setFromMatrixPosition(light.target.matrixWorld).sub(position).normalize();
413
+ out.push({
414
+ id,
415
+ kind: "spot",
416
+ position: [position.x, position.y, position.z],
417
+ direction: [target.x, target.y, target.z],
418
+ color,
419
+ distance: light.distance,
420
+ decay: light.decay,
421
+ cosAngle: Math.cos(light.angle),
422
+ cosPenumbra: Math.cos(light.angle * (1.0 - light.penumbra)),
423
+ ...(shadow ? { shadow } : {}),
424
+ });
425
+ }
426
+ else if (light.isPointLight) {
427
+ out.push({ id, kind: "point", position: [position.x, position.y, position.z], color, distance: light.distance, decay: light.decay, ...(shadow ? { shadow } : {}) });
428
+ }
429
+ });
430
+ return { lights: out, emissionLight, shadowLights };
431
+ }
432
+ /**
433
+ * @internal K6.8a: the core volume a frame volume draws as (null before its first render with this renderer). Its
434
+ * `slot.source` is the core source the frame renderer made for it; a sparse volume's pyramids live there (its
435
+ * `gpuBytes`), not in the three source (demo 15's GPU bytes).
436
+ */
437
+ coreVolumeOf(frameVolume) {
438
+ return this.#volumes.get(frameVolume) ?? null;
439
+ }
440
+ /** Frees the core renderer, its stand-ins and the shadow filters. A later render makes them again. */
441
+ dispose() {
442
+ // NOTE Puts back the shadow filter of each light; the receivers build again without the volume shadow
443
+ this.volumeShadows.dispose();
444
+ this.#core?.dispose();
445
+ this.#core = null;
446
+ this.#device = null;
447
+ this.#environment.dispose();
448
+ this.#prefix.dispose();
449
+ this.#alphaPrefix.dispose();
450
+ this.#material?.dispose();
451
+ this.#material = null;
452
+ this.#volumes = new Map();
453
+ this.#disposeSparse();
454
+ this.#frameKey = null;
455
+ this.#cachedFrame = -1;
456
+ this.#cachedCamera = null;
457
+ }
458
+ }
459
+ /** Per three renderer shared instances (`vdbFrameRenderer(renderer)`). */
460
+ const sharedByRenderer = new WeakMap();
461
+ let shared = null;
462
+ /**
463
+ * The shared {@link VDBFrameRenderer} that a `VDBFrameVolume` uses when you pass no `frameRenderer`.
464
+ * Its `settings` are global to every volume that uses it (the froxel grid, shadows and scattering are
465
+ * built once for all of them). Pass a three renderer to get the instance shared by that renderer only
466
+ * (a WeakMap, so two three renderers never share targets or settings); with no argument you get the
467
+ * one process-wide default. For volumes that need different settings, make your own
468
+ * `new VDBFrameRenderer()` and pass it as `VDBFrameVolume({ frameRenderer })`.
469
+ */
470
+ export function vdbFrameRenderer(renderer) {
471
+ if (renderer) {
472
+ let r = sharedByRenderer.get(renderer);
473
+ if (!r)
474
+ sharedByRenderer.set(renderer, (r = new VDBFrameRenderer()));
475
+ return r;
476
+ }
477
+ shared ??= new VDBFrameRenderer();
478
+ return shared;
479
+ }
480
+ //# sourceMappingURL=renderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderer.js","sourceRoot":"","sources":["../../../src/three/frame/renderer.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,mHAAmH;AACnH,uHAAuH;AACvH,6BAA6B;AAC7B,4GAA4G;AAC5G,wHAAwH;AACxH,qHAAqH;AACrH,kBAAkB;AAElB;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,qBAAqB,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CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5B,CAAC;CACF;AAED,0EAA0E;AAC1E,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA4B,CAAC;AACjE,IAAI,MAAM,GAA4B,IAAI,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAiB;IAChD,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,CAAC,GAAG,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,CAAC;YAAE,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,IAAI,gBAAgB,EAAE,CAAC,CAAC,CAAC;QACrE,OAAO,CAAC,CAAC;IACX,CAAC;IACD,MAAM,KAAK,IAAI,gBAAgB,EAAE,CAAC;IAClC,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/FrameRenderer.js L191–246 (the settings; now the core's), L431–481 (render: the\n// first proxy of a render draws the frame, override passes draw nothing), L1476–1716 (visitLight: the scene's lights\n// in the camera's layers).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes (K6.8): the TSL passes are gone; every frame is the core frame renderer (`vdbCreateFrameRenderer`, compute on\n// three's device), recorded into its own encoder and submitted before three's frame. Divergences: DIVERGES.md (K3.1,\n// K3.3, K6 rows).\n\n/**\n * The froxel renderer of `./three` (K6.8, design §6): a thin adapter over the core frame renderer. One\n * core `VDBFrameRenderer` per three renderer device; in the first `VDBFrameVolume` proxy's `onBeforeRender` of a render (or\n * a volume shadow receiver's / the emission light's `updateBefore`, whichever comes first) it collects the volumes in the\n * camera's layers, converts the scene's lights (shadow cameras → volume shadow requests, three's shadow maps →\n * occluders), passes `scene.environment`, records `core.update()` into its own encoder and submits; three's frame\n * submits after it. Every proxy then draws the composite material over three's scene depth and colour.\n */\n\nimport * as THREE from \"three\";\nimport type { WebGPURenderer } from \"three/webgpu\";\nimport { vdbFrameMlpFromNeural, type VDBFrameMlp } from \"../../tools/frame/mlp.js\";\nimport { vdbFrameNeuralWeights } from \"../../tools/frame/neural-weights.js\";\nimport { vdbFrameDefaultSettings, type VDBFrameSettings } from \"../../core/frame/settings.js\";\nimport { vdbCreateFrameRenderer, type VDBFrameRenderer as VDBCoreFrameRenderer } from \"../../core/frame/renderer.js\";\nimport type { VDBEmissionColor, VDBFrameEmissionLightSettings, VDBFrameLight, VDBFrameRedrawStats, VDBFrameTimestamps, VDBFrameUpdate, VDBFrameVolume as VDBCoreFrameVolume, VDBFrameVolumeParams, VDBVolumeShadowRequest } from \"../../core/frame/types.js\";\nimport { vdbSparseSource as vdbCoreSparseSource, type VDBSparseSource as VDBCoreSparseSource, type VDBSparseVolume as VDBCoreSparseVolume } from \"../../core/source/sparse.js\";\nimport { vdbDenseSource, type VDBDenseSource } from \"../../core/source/dense.js\";\nimport type { VDBGridPool } from \"../../core/pool/pool.js\";\nimport type { VDBGridTypeName } from \"../../core/types.js\";\nimport type { VDBThreeDenseSource } from \"../volume-source.js\";\nimport type { VDBIndexBox, VDBThreeSparseSource } from \"../sparse-source.js\";\nimport { getDevice } from \"../device.js\";\nimport { vdbFrameRenderId } from \"./three-internals.js\";\nimport { VDBCoreTextureBinding, vdbCoreTextureSelfTest } from \"./core-textures.js\";\nimport { VDBFrameCoreIntegrateMaterial } from \"./core-integrate-material.js\";\nimport { VDBCoreOccluders } from \"./core-occluders.js\";\nimport { VDBCoreEnvironment } from \"./core-environment.js\";\nimport { VDBFrameVolumeShadowReceivers } from \"./volume-shadows.js\";\nimport { getFrameAngstromExponent } from \"./spectrum.js\";\nimport type { VDBFrameVolume } from \"./volume.js\";\n\n/**\n * Hooks around each core update (K6.8; not his). `timestampWrites` brackets the kernels the update records (a\n * `'timestamp'` query set and two indices: written at the start and the end of the update's GPU work); resolve and\n * read the set yourself. `begin` / `end` run on the CPU around the update's recording and submit.\n */\nexport interface VDBFramePassHook {\n timestampWrites?: VDBFrameTimestamps | null;\n begin?(): void;\n end?(update: VDBFrameUpdate): void;\n}\n\n/** Our trained network (K6.N, D36) as the core MLP (the default `mlp`; one object, so the core uploads it once). */\nconst DEFAULT_MLP = vdbFrameMlpFromNeural(vdbFrameNeuralWeights);\n\ntype RendererLike = WebGPURenderer & { isWebGPURenderer?: boolean };\ntype SceneLike = THREE.Object3D & { overrideMaterial?: THREE.Material | null; environment?: THREE.Texture | null; environmentIntensity?: number; environmentRotation?: THREE.Euler };\n\n/** Instanced, so a proxy skips its draw with `instanceCount = 0` (three draws no instances). A quad the composite places. */\nconst proxyQuad = new THREE.Float32BufferAttribute([-1, -1, 0, 1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, 1, 0], 3);\n\n/** His `FrameRenderer`, on the core: one instance can serve many volumes and cameras. */\nexport class VDBFrameRenderer {\n /**\n * The settings (the core's `VDBFrameSettings`: his names and v0.26 defaults plus the K6 fields); live, read at the\n * next render and shared by every volume this renderer draws.\n */\n settings: VDBFrameSettings = vdbFrameDefaultSettings();\n\n /**\n * EXPERIMENTAL: the network of `multipleScattering` `'mlp'` / `'neural'` as `VDBFrameMlp` data (layer shapes,\n * activations, weights; default: mjurczyk's trained weights). Assign another network of that form (no rebuild), or\n * null to run those modes as 1D diffusion (warned).\n */\n mlp: VDBFrameMlp | null = DEFAULT_MLP;\n\n /** Timing and debug hooks around each core update ({@link VDBFramePassHook}). */\n passHook: VDBFramePassHook | null = null;\n\n /**\n * Whether the volumes are drawn into the froxels at the next render (default true). False keeps the last froxels\n * (the composite still draws them; volume shadow maps and probes still update): `update(…, { froxels: false })`.\n */\n froxels = true;\n\n #core: VDBCoreFrameRenderer | null = null;\n #device: GPUDevice | null = null;\n #material: VDBFrameCoreIntegrateMaterial | null = null;\n readonly #prefix = new VDBCoreTextureBinding();\n /** K6.4: the stand-in of the spectral alpha prefix (`outputs.froxels.integratedAlpha`). */\n readonly #alphaPrefix = new VDBCoreTextureBinding();\n #denseSources = new WeakMap<object, VDBDenseSource>();\n #sparseSources = new Map<object, Map<string, VDBCoreSparseSource>>();\n #sparseSlots = new WeakMap<object, VDBCoreSparseVolume>();\n /** The three source's stats object each core slot last took (a new object: `refreshStats()` ran). */\n #slotStats = new WeakMap<object, object>();\n #volumes = new Map<VDBFrameVolume, VDBCoreFrameVolume>();\n #frameId = 0;\n #frameKey: { renderId: number; camera: THREE.Camera; scene: object; result: VDBFrameUpdate } | null = null;\n #cachedFrame = -1;\n #cachedCamera: THREE.Camera | null = null;\n #rendererWarned = false;\n /** K6.5b: three's shadow maps as the core's occluder maps. */\n readonly #occluders = new VDBCoreOccluders();\n /** K6.2b: `scene.environment` as the core's environment input. */\n readonly #environment = new VDBCoreEnvironment();\n /** @internal K6.5: volume shadows on meshes: the shadow filter on each shadow light, reading the core's maps. */\n readonly volumeShadows: VDBFrameVolumeShadowReceivers = new VDBFrameVolumeShadowReceivers(this);\n\n /** The core frame renderer (made at the first render, per device; null before). Read its `outputs`; set nothing on it. */\n get core(): VDBCoreFrameRenderer | null {\n return this.#core;\n }\n\n /** Redraws and skips of the core's signature-cached passes ('frame' lighting) and volume shadow pieces (zeros before the first render). */\n get redrawStats(): VDBFrameRedrawStats {\n return this.#core?.redrawStats ?? { shadowDensity: { drawn: 0, skipped: 0 }, transmittance: { drawn: 0, skipped: 0 }, environmentGrid: { drawn: 0, skipped: 0 }, volumeShadows: { drawn: 0, waiting: 0 } };\n }\n\n /** The composite material every volume proxy draws (one per renderer). */\n proxyMaterial(): THREE.Material {\n this.#material ??= new VDBFrameCoreIntegrateMaterial();\n return this.#material;\n }\n\n /** A quad geometry for a volume proxy; the composite places it over the froxel area. */\n createProxyGeometry(): THREE.InstancedBufferGeometry {\n const geometry = new THREE.InstancedBufferGeometry();\n geometry.instanceCount = 1;\n geometry.setAttribute(\"position\", proxyQuad);\n return geometry;\n }\n\n /**\n * Called by each volume proxy before it draws: the first proxy of a render runs the core update (once per render,\n * camera and scene); every proxy then composites the froxels. Override passes (depth, normals) draw nothing.\n */\n render(renderer: RendererLike, scene: SceneLike, camera: THREE.Camera, proxy: THREE.Mesh<THREE.InstancedBufferGeometry>): void {\n if (!renderer.isWebGPURenderer) {\n if (!this.#rendererWarned) {\n console.error(\"VDBFrameVolume: needs WebGPURenderer (three/webgpu).\");\n this.#rendererWarned = true;\n }\n return;\n }\n if (scene.overrideMaterial) {\n proxy.geometry.instanceCount = 0;\n return;\n }\n const frame = renderer.info.render.calls;\n if (frame === this.#cachedFrame && camera === this.#cachedCamera) {\n proxy.geometry.instanceCount = 0;\n return;\n }\n const material = this.proxyMaterial() as VDBFrameCoreIntegrateMaterial;\n // NOTE three draws the material it chose before onBeforeRender: a swapped proxy draws the composite from the next frame\n if (proxy.material !== material) proxy.material = material;\n const u = this.coreFrame(renderer, scene, camera);\n if (u?.recorded && u.outputs.froxels) {\n if (this.#prefix.set(u.outputs.froxels.integrated)) material.prefix.value = this.#prefix.texture;\n // K6.4: spectral media composite with the alpha prefix (their own blend over three's viewport texture)\n const alpha = u.outputs.froxels.integratedAlpha;\n if (alpha && this.#alphaPrefix.set(alpha)) material.alphaPrefix.value = this.#alphaPrefix.texture;\n material.setSpectral(!!alpha);\n material.setLayout(u.outputs.froxels.layout, camera as THREE.PerspectiveCamera);\n material.setSrgbBlending(this.settings.srgbBlending && renderer.outputColorSpace === THREE.SRGBColorSpace, renderer.toneMapping === THREE.NoToneMapping);\n }\n this.#cachedFrame = renderer.info.render.calls;\n this.#cachedCamera = camera;\n proxy.geometry.instanceCount = u?.recorded ? 1 : 0;\n }\n\n /**\n * The core update of one render, recorded into its own encoder and submitted (three's frame submits after it, so queue\n * order is right). It runs once per render id, camera and scene; the first caller runs it: a volume shadow receiver's\n * or the emission light's `updateBefore` (before any receiver of the render draws, his order), else the first volume\n * proxy. The volume shadow maps and the emission probes are drawn here.\n */\n coreFrame(renderer: RendererLike, scene: SceneLike, camera: THREE.Camera): VDBFrameUpdate | null {\n if (!renderer.isWebGPURenderer) return null;\n const renderId = vdbFrameRenderId(renderer);\n const key = this.#frameKey;\n if (key && key.renderId === renderId && key.camera === camera && key.scene === scene) return key.result;\n const device = getDevice(renderer as never);\n if (!this.#core || this.#device !== device) {\n vdbCoreTextureSelfTest(renderer as never, device);\n this.#core?.dispose();\n this.#core = vdbCreateFrameRenderer(device, { label: \"vdb three frame\" });\n this.#device = device;\n this.#denseSources = new WeakMap();\n this.#volumes = new Map();\n this.#disposeSparse();\n }\n const core = this.#core;\n Object.assign(core.settings, this.settings);\n core.mlp = this.mlp;\n // K6.5: the volume shadow filter on each shadow light (receivers build with it from the next render)\n this.volumeShadows.update(renderer, scene);\n\n const seen = new Set<VDBCoreFrameVolume>();\n scene.traverseVisible((object) => {\n const frameVolume = object as VDBFrameVolume;\n if (!frameVolume.isVDBFrameVolume || frameVolume.frameRenderer !== this || !frameVolume.proxy.layers.test(camera.layers)) return;\n frameVolume.syncSource();\n const handle = this.#volumeOf(frameVolume, device);\n frameVolume.boxMatrixWorld.multiplyMatrices(frameVolume.matrixWorld, frameVolume.boxMatrix);\n this.#setParams(handle.params, frameVolume, frameVolume.boxMatrixWorld);\n handle.visible = true;\n // his collector: every volume in the camera's layers casts into the shadow grid, also out of view\n handle.castsShadow = true;\n seen.add(handle);\n });\n for (const [frameVolume, handle] of this.#volumes) {\n if (seen.has(handle)) continue;\n // a volume that is hidden (or out of the camera's layers) neither draws nor casts (Traps: the core casts invisible volumes)\n handle.visible = false;\n handle.castsShadow = false;\n if (!frameVolume.parent) {\n handle.remove();\n this.#volumes.delete(frameVolume);\n }\n }\n\n const cam = camera as THREE.PerspectiveCamera & { isOrthographicCamera?: boolean };\n const buffer = renderer.getDrawingBufferSize(new THREE.Vector2());\n const canvas = renderer.getSize(new THREE.Vector2());\n const { lights, emissionLight, shadowLights } = this.#lights(scene, camera);\n // K6.5b: three draws its pending shadow maps now (before this update's submit), so the occluders are this frame's\n const occluders = this.settings.occlusion ? this.#occluders.input(renderer as never, scene, camera, shadowLights) : [];\n const hook = this.passHook;\n hook?.begin?.();\n const encoder = device.createCommandEncoder({ label: \"vdb three frame\" });\n const u = core.update(\n encoder,\n {\n frameId: this.#frameId++,\n camera: {\n view: camera.matrixWorldInverse.elements,\n projection: camera.projectionMatrix.elements,\n near: cam.near,\n far: cam.far,\n orthographic: !!cam.isOrthographicCamera,\n reversedDepth: !!(renderer as unknown as { reversedDepthBuffer?: boolean }).reversedDepthBuffer,\n id: camera.id,\n },\n viewport: { drawingBuffer: [buffer.x, buffer.y], canvas: [canvas.x, canvas.y] },\n lights,\n emissionLight,\n environment: this.#environment.input(renderer as never, scene),\n occluders,\n },\n { froxels: this.froxels, ...(hook?.timestampWrites ? { timestampWrites: hook.timestampWrites } : {}) },\n );\n device.queue.submit([encoder.finish()]);\n // K6.5: the receivers read the maps with the state they were drawn with (copied to their uniforms now, before they draw)\n this.volumeShadows.sync(u.outputs.volumeShadows, core.redrawStats.volumeShadows);\n hook?.end?.(u);\n this.#frameKey = { renderId, camera, scene, result: u };\n return u;\n }\n\n /** The core volume of a frame volume: its dense source uploaded once on the core side, or a slot of a sparse source. */\n #volumeOf(frameVolume: VDBFrameVolume, device: GPUDevice): VDBCoreFrameVolume {\n if (frameVolume.source.kind !== \"dense\") return this.#sparseVolumeOf(frameVolume);\n const three = frameVolume.source as VDBThreeDenseSource;\n let source = this.#denseSources.get(three);\n if (!source) {\n source = vdbDenseSource(device, three.volume, { label: \"vdb three dense\" });\n this.#denseSources.set(three, source);\n } else if (source.volume !== three.volume) {\n source.replace(three.volume);\n }\n let handle = this.#volumes.get(frameVolume);\n if (handle && handle.slot.source !== source) {\n handle.remove();\n handle = undefined;\n }\n if (!handle) {\n handle = this.#core!.addVolume(source);\n this.#volumes.set(frameVolume, handle);\n }\n return handle;\n }\n\n /**\n * K6.1d: the core volume of a frame volume on a sparse source: one core `vdbSparseSource` per pool and source options\n * (its pyramids are the core's own), one slot per three source with the same grids, boxes and stats. K6.8a: the three\n * source is a handle; its TSL half (and its own pyramid) is never made here.\n */\n #sparseVolumeOf(frameVolume: VDBFrameVolume): VDBCoreFrameVolume {\n const three = frameVolume.source as VDBThreeSparseSource & {\n auxBoxes?: Record<\"mask\" | \"albedo\" | \"emission\", VDBIndexBox | null>;\n pyramidOptions?: { pyramidMax?: number };\n brickCache?: \"off\" | \"f32\" | \"f16\";\n brickOptions?: Record<string, unknown>;\n };\n const pool = three.grids.pool as unknown as VDBGridPool;\n const types = (three.grids.options as { types?: readonly VDBGridTypeName[] }).types;\n const options = {\n lod: three.lod,\n normalize: three.normalize,\n followImage: three.followImage,\n fastTrilinear: three.fastTrilinear,\n cacheAccessor: three.cacheAccessor,\n ...(three.pyramidOptions?.pyramidMax !== undefined ? { pyramidMax: three.pyramidOptions.pyramidMax } : {}),\n ...(types ? { types } : {}),\n // K3.2f (internal): the brick cache; absent when off, so the key (and the source) is the one without it\n ...(three.brickCache && three.brickCache !== \"off\" ? { brickCache: three.brickCache, ...three.brickOptions } : {}),\n };\n const key = JSON.stringify(options);\n let byKey = this.#sparseSources.get(pool);\n if (!byKey) this.#sparseSources.set(pool, (byKey = new Map()));\n let source = byKey.get(key);\n if (!source) {\n source = vdbCoreSparseSource(pool, { ...options, label: \"vdb three sparse\" });\n byKey.set(key, source);\n }\n let handle = this.#volumes.get(frameVolume);\n let slot = this.#sparseSlots.get(three);\n if (!slot || slot.source !== source || slot.removed) {\n slot?.remove();\n const aux = three.auxBoxes ?? { mask: null, albedo: null, emission: null };\n const auxIndexBoxes = Object.fromEntries(Object.entries(aux).filter(([, b]) => b)) as Partial<Record<\"mask\" | \"albedo\" | \"emission\", VDBIndexBox>>;\n slot = source.volume(three.ids, three.followImage ? { stats: three.stats } : { indexBox: three.indexBox, auxIndexBoxes, stats: three.stats });\n this.#sparseSlots.set(three, slot);\n this.#slotStats.set(slot, three.stats);\n } else if (this.#slotStats.get(slot) !== three.stats) {\n // the three source re-read its stats (`refreshStats()` after a replace): the core slot takes them now, instead of\n // a frame or two later from its own readback of the same image (a coarse-first swap's first full frame, G16a)\n (slot as { stats: VDBCoreSparseVolume[\"stats\"] }).stats = { ...three.stats };\n this.#slotStats.set(slot, three.stats);\n }\n if (handle && handle.slot !== slot) {\n handle.remove();\n handle = undefined;\n }\n if (!handle) {\n handle = this.#core!.addVolume(slot);\n this.#volumes.set(frameVolume, handle);\n }\n return handle;\n }\n\n /** Frees the sparse sources (their slots and pyramids); the pools are the host's. */\n #disposeSparse(): void {\n for (const byKey of this.#sparseSources.values()) for (const s of byKey.values()) s.dispose();\n this.#sparseSources = new Map();\n this.#sparseSlots = new WeakMap();\n }\n\n /** A frame volume's props as the core's params. */\n #setParams(p: VDBFrameVolumeParams, v: VDBFrameVolume, matrixWorld: THREE.Matrix4): void {\n const wrap = v.wrap3D === THREE.RepeatWrapping ? \"repeat\" : v.wrap3D === THREE.MirroredRepeatWrapping ? \"mirror\" : \"clamp\";\n const params: VDBFrameVolumeParams = {\n matrixWorld: matrixWorld.elements.slice(),\n baseColor: [v.baseColor.r, v.baseColor.g, v.baseColor.b],\n scatterColor: [v.scatterColor.r, v.scatterColor.g, v.scatterColor.b],\n extinction: v.extinction,\n extinctionScale: [v.extinctionScale.x, v.extinctionScale.y, v.extinctionScale.z],\n // K6.4: a preset name ('smoke', 'air', …) or a number (his getFrameAngstromExponent)\n angstromExponent: getFrameAngstromExponent(v.angstromExponent),\n densityScale: v.densityScale,\n normalizeDensity: v.normalizeDensity,\n densityMean: v.densityMean,\n densityCutoff: v.densityCutoff,\n absorbance: v.absorbance,\n opacity: v.opacity,\n emissiveIntensity: v.emissiveIntensity,\n temperatureRange: [v.temperatureRange.x, v.temperatureRange.y],\n offset3D: [v.offset3D.x, v.offset3D.y, v.offset3D.z],\n wrap3D: wrap,\n lights: v.lights,\n shadowSteps: v.shadowSteps,\n mipmaps: v.mipmaps,\n hdda: v.hdda,\n phase: v.phase,\n phaseG: v.phaseG,\n phaseBackG: v.phaseBackG,\n phaseBackWeight: v.phaseBackWeight,\n phaseGExponent: v.phaseGExponent,\n emissionColor: this.#emissionColor(v),\n };\n Object.assign(p, params);\n }\n\n /** K6.5: the volume's emission colour as core data ('white' when unset). */\n #emissionColor(v: VDBFrameVolume): VDBEmissionColor {\n return v.emissionColor ?? \"white\";\n }\n\n /**\n * The scene's lights in the camera's layers as core lights (his visitLight). K6.5: a shadow light with the volume\n * shadow filter on it asks for a volume shadow map (spot: the light's own shadow camera, so both maps share one texel\n * grid; point: its cube near / far; directional: cascades fitted by the core); a `VDBFrameEmissionLight` gives the\n * emission probe settings.\n */\n #lights(scene: THREE.Object3D, camera: THREE.Camera): { lights: VDBFrameLight[]; emissionLight: VDBFrameEmissionLightSettings | null; shadowLights: THREE.Light[] } {\n const out: VDBFrameLight[] = [];\n // K6.5b: the directional, spot and point lights passed (their shadow maps are the occluders)\n const shadowLights: THREE.Light[] = [];\n let emissionLight: VDBFrameEmissionLightSettings | null = null;\n const position = new THREE.Vector3();\n const target = new THREE.Vector3();\n const size = this.volumeShadows.getMapSize();\n scene.traverseVisible((object) => {\n const light = object as THREE.Light & {\n isAmbientLight?: boolean;\n isHemisphereLight?: boolean;\n isLightProbe?: boolean;\n isDirectionalLight?: boolean;\n isSpotLight?: boolean;\n isPointLight?: boolean;\n isVDBFrameEmissionLight?: boolean;\n groundColor?: THREE.Color;\n sh?: { coefficients: THREE.Vector3[] };\n target?: THREE.Object3D;\n angle?: number;\n penumbra?: number;\n distance?: number;\n decay?: number;\n };\n if (!light.isLight || !light.layers.test(camera.layers)) return;\n if (light.isVDBFrameEmissionLight) {\n if (!emissionLight) {\n const e = light as unknown as Required<VDBFrameEmissionLightSettings>;\n emissionLight = { resolution: e.resolution, range: e.range, cascades: e.cascades, distance: e.distance, steps: Math.max(1, Math.round(e.steps)) };\n }\n return;\n }\n const i = light.intensity;\n const color: [number, number, number] = [light.color.r * i, light.color.g * i, light.color.b * i];\n position.setFromMatrixPosition(light.matrixWorld);\n const id = light.id;\n // K6.5: a map for each light the volume shadow filter is on (volumeShadows.update installed it)\n let shadow: VDBVolumeShadowRequest | undefined;\n if (this.settings.castShadows && light.castShadow && this.volumeShadows.entries.has(light)) {\n if (light.isSpotLight) {\n (light as unknown as THREE.SpotLight).shadow.updateMatrices(light as unknown as THREE.SpotLight);\n const c = (light as unknown as THREE.SpotLight).shadow.camera;\n shadow = { size, view: { viewProjection: new THREE.Matrix4().multiplyMatrices(c.projectionMatrix, c.matrixWorldInverse).elements, near: c.near, far: c.far, orthographic: false } };\n } else if (light.isPointLight) {\n const c = (light as unknown as THREE.SpotLight).shadow.camera;\n shadow = { size, view: { near: c.near, far: light.distance || c.far } };\n } else if (light.isDirectionalLight) shadow = { size, view: \"fit\" };\n }\n if ((light.isDirectionalLight || light.isSpotLight || light.isPointLight) && light.castShadow) shadowLights.push(light);\n if (light.isAmbientLight) out.push({ id, kind: \"ambient\", color });\n else if (light.isHemisphereLight) {\n const g = light.groundColor!;\n const up = position.lengthSq() > 0 ? position.clone().normalize() : new THREE.Vector3(0, 1, 0);\n out.push({ id, kind: \"hemisphere\", sky: color, ground: [g.r * i, g.g * i, g.b * i], up: [up.x, up.y, up.z] });\n } else if (light.isLightProbe) {\n out.push({ id, kind: \"probe\", sh: light.sh!.coefficients.flatMap((c) => [c.x * i, c.y * i, c.z * i]) });\n } else if (light.isDirectionalLight) {\n target.setFromMatrixPosition(light.target!.matrixWorld).sub(position).normalize();\n out.push({ id, kind: \"directional\", direction: [target.x, target.y, target.z], color, ...(shadow ? { shadow } : {}) });\n } else if (light.isSpotLight) {\n target.setFromMatrixPosition(light.target!.matrixWorld).sub(position).normalize();\n out.push({\n id,\n kind: \"spot\",\n position: [position.x, position.y, position.z],\n direction: [target.x, target.y, target.z],\n color,\n distance: light.distance!,\n decay: light.decay!,\n cosAngle: Math.cos(light.angle!),\n cosPenumbra: Math.cos(light.angle! * (1.0 - light.penumbra!)),\n ...(shadow ? { shadow } : {}),\n });\n } else if (light.isPointLight) {\n out.push({ id, kind: \"point\", position: [position.x, position.y, position.z], color, distance: light.distance!, decay: light.decay!, ...(shadow ? { shadow } : {}) });\n }\n });\n return { lights: out, emissionLight, shadowLights };\n }\n\n /**\n * @internal K6.8a: the core volume a frame volume draws as (null before its first render with this renderer). Its\n * `slot.source` is the core source the frame renderer made for it; a sparse volume's pyramids live there (its\n * `gpuBytes`), not in the three source (demo 15's GPU bytes).\n */\n coreVolumeOf(frameVolume: VDBFrameVolume): VDBCoreFrameVolume | null {\n return this.#volumes.get(frameVolume) ?? null;\n }\n\n /** Frees the core renderer, its stand-ins and the shadow filters. A later render makes them again. */\n dispose(): void {\n // NOTE Puts back the shadow filter of each light; the receivers build again without the volume shadow\n this.volumeShadows.dispose();\n this.#core?.dispose();\n this.#core = null;\n this.#device = null;\n this.#environment.dispose();\n this.#prefix.dispose();\n this.#alphaPrefix.dispose();\n this.#material?.dispose();\n this.#material = null;\n this.#volumes = new Map();\n this.#disposeSparse();\n this.#frameKey = null;\n this.#cachedFrame = -1;\n this.#cachedCamera = null;\n }\n}\n\n/** Per three renderer shared instances (`vdbFrameRenderer(renderer)`). */\nconst sharedByRenderer = new WeakMap<object, VDBFrameRenderer>();\nlet shared: VDBFrameRenderer | null = null;\n\n/**\n * The shared {@link VDBFrameRenderer} that a `VDBFrameVolume` uses when you pass no `frameRenderer`.\n * Its `settings` are global to every volume that uses it (the froxel grid, shadows and scattering are\n * built once for all of them). Pass a three renderer to get the instance shared by that renderer only\n * (a WeakMap, so two three renderers never share targets or settings); with no argument you get the\n * one process-wide default. For volumes that need different settings, make your own\n * `new VDBFrameRenderer()` and pass it as `VDBFrameVolume({ frameRenderer })`.\n */\nexport function vdbFrameRenderer(renderer?: object): VDBFrameRenderer {\n if (renderer) {\n let r = sharedByRenderer.get(renderer);\n if (!r) sharedByRenderer.set(renderer, (r = new VDBFrameRenderer()));\n return r;\n }\n shared ??= new VDBFrameRenderer();\n return shared;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ /** Measured Ångström exponents (his VDB-116 research; Dubovik 2002, Bodhaine 1999). */
2
+ export declare const frameAngstromExponents: Readonly<Record<string, number>>;
3
+ /** A preset name of {@link frameAngstromExponents} or a number. Unknown names give 0 (grey). */
4
+ export declare const getFrameAngstromExponent: (value: string | number | undefined) => number;
@@ -0,0 +1,15 @@
1
+ // Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
2
+ // src/three-openvdb/frame/core/frameSpectrum.js (the Ångström presets and getFrameAngstromExponent).
3
+ // Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
4
+ // Changes: TypeScript; K6.8: only the preset lookup is left (the core packs the extinction spectrum).
5
+ const toNumber = (value, fallback) => (Number.isFinite(Number(value)) ? Number(value) : fallback);
6
+ /** Measured Ångström exponents (his VDB-116 research; Dubovik 2002, Bodhaine 1999). */
7
+ export const frameAngstromExponents = {
8
+ cloud: 0.0,
9
+ dust: 0.3,
10
+ smoke: 1.8,
11
+ air: 4.09,
12
+ };
13
+ /** A preset name of {@link frameAngstromExponents} or a number. Unknown names give 0 (grey). */
14
+ export const getFrameAngstromExponent = (value) => typeof value === "string" ? (frameAngstromExponents[value] ?? 0.0) : toNumber(value, 0.0);
15
+ //# sourceMappingURL=spectrum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spectrum.js","sourceRoot":"","sources":["../../../src/three/frame/spectrum.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,uGAAuG;AACvG,4GAA4G;AAC5G,sGAAsG;AAEtG,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAE,QAAgB,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAEnH,uFAAuF;AACvF,MAAM,CAAC,MAAM,sBAAsB,GAAqC;IACtE,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,GAAG;IACT,KAAK,EAAE,GAAG;IACV,GAAG,EAAE,IAAI;CACV,CAAC;AAEF,gGAAgG;AAChG,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,KAAkC,EAAE,EAAE,CAC7E,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/frameSpectrum.js (the Ångström presets and getFrameAngstromExponent).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; K6.8: only the preset lookup is left (the core packs the extinction spectrum).\n\nconst toNumber = (value: unknown, fallback: number) => (Number.isFinite(Number(value)) ? Number(value) : fallback);\n\n/** Measured Ångström exponents (his VDB-116 research; Dubovik 2002, Bodhaine 1999). */\nexport const frameAngstromExponents: Readonly<Record<string, number>> = {\n cloud: 0.0,\n dust: 0.3,\n smoke: 1.8,\n air: 4.09,\n};\n\n/** A preset name of {@link frameAngstromExponents} or a number. Unknown names give 0 (grey). */\nexport const getFrameAngstromExponent = (value: string | number | undefined) =>\n typeof value === \"string\" ? (frameAngstromExponents[value] ?? 0.0) : toNumber(value, 0.0);\n"]}