@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,766 @@
1
+ /**
2
+ * read.ts — `.wvdb` reader (mjurczyk's WebVDB spec v0.5.x, file versions 1
3
+ * and 2): header parsing and validation (§4, §5, §14), whole-file decode, and
4
+ * coarse-first decode from a prefix, a byte range, or a stream (§9, §12.2).
5
+ *
6
+ * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345: the chunk
7
+ * walk mirrors `getWVDBChunks` in `src/openvdb/wvdb/format.js`, and the
8
+ * per-LOD layout rule (a LOD is sparse iff it has a `mask`) mirrors
9
+ * `WVDBReader.getKernelGrid` in `src/three-openvdb/wvdb/WVDBReader.js`.
10
+ *
11
+ * The stream reader decodes chunk by chunk (K4.13), so it holds one chunk's
12
+ * compressed bytes at a time and can show a LOD before all its pages arrive.
13
+ *
14
+ * Decoded volume LODs are dense `Float32Array`s: channel planes one after the
15
+ * other (`values[c * X*Y*Z + x + y*X + z*X*Y]`), x fastest. Voxels of bricks a
16
+ * sparse LOD does not store hold the background (§12.2.3); voxels of a brick
17
+ * outside the LOD are dropped (§3.3). Values are float32, computed exactly as
18
+ * his `decodeWVDBPage` computes them.
19
+ */
20
+ import { VDBToolsError } from "../errors.js";
21
+ import { unzlibSync } from "fflate";
22
+ import { WVDB_BRICK_DIM, WVDB_BRICK_VOXELS, WVDB_MAGIC, WVDB_POINTS_VERSION, WVDB_PREAMBLE_SIZE, WVDB_SUPPORTED_VERSIONS, WvdbFormatError, brickCounts, brickOrigin, brickTotal, decodeMask, decodePage, decodePoints, isMaskBitSet, isPointsGridHeader, maskByteSize, pageByteSize, pointsChunkByteSize, } from "./format.js";
23
+ const DEFAULT_MAX_VOXELS = 2 ** 28;
24
+ const KNOWN_CLASSES = ["fog volume", "level set", "staggered", "unknown"];
25
+ /** §5.4: any other class string reads as `"unknown"`. */
26
+ export function normalizeWvdbClass(value) {
27
+ return (KNOWN_CLASSES.includes(value) ? value : "unknown");
28
+ }
29
+ /**
30
+ * Reads the preamble and header. Returns `null` while `bytes` (a prefix of
31
+ * the file) does not yet hold the whole header; throws `WvdbFormatError` on a
32
+ * bad magic, an unsupported version, or a header that breaks §5/§14.
33
+ * @param bytes A prefix of the file (at least the preamble to get anything back).
34
+ * @param opts Limits and optional checks.
35
+ */
36
+ export function readWvdbHeader(bytes, opts = {}) {
37
+ if (bytes.byteLength >= 4) {
38
+ for (let i = 0; i < 4; i++) {
39
+ if (bytes[i] !== WVDB_MAGIC.charCodeAt(i))
40
+ throw new WvdbFormatError("not a WVDB file (bad magic)");
41
+ }
42
+ }
43
+ if (bytes.byteLength < WVDB_PREAMBLE_SIZE)
44
+ return null;
45
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
46
+ const version = view.getUint32(4, true);
47
+ if (!WVDB_SUPPORTED_VERSIONS.includes(version)) {
48
+ throw new WvdbFormatError(`version ${version} is not supported (this reader reads 1 and 2)`);
49
+ }
50
+ const headerLength = view.getUint32(8, true);
51
+ if (opts.fileLength !== undefined && headerLength > opts.fileLength - WVDB_PREAMBLE_SIZE) {
52
+ throw new WvdbFormatError(`headerLength ${headerLength} is more than the file length minus 12`);
53
+ }
54
+ const dataStart = WVDB_PREAMBLE_SIZE + headerLength;
55
+ if (bytes.byteLength < dataStart)
56
+ return null;
57
+ let parsed;
58
+ try {
59
+ // fatal: invalid UTF-8 throws; ignoreBOM: a BOM stays in the text, so JSON.parse rejects it (§4).
60
+ const text = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes.subarray(WVDB_PREAMBLE_SIZE, dataStart));
61
+ parsed = JSON.parse(text);
62
+ }
63
+ catch (err) {
64
+ throw new WvdbFormatError(`header is not valid UTF-8 JSON: ${err.message}`);
65
+ }
66
+ const header = validateHeader(parsed, version, opts);
67
+ if (opts.fileLength !== undefined) {
68
+ const dataLength = opts.fileLength - dataStart;
69
+ for (const chunk of wvdbChunks(header)) {
70
+ if (chunk.offset + chunk.length > dataLength) {
71
+ throw new WvdbFormatError(`chunk (${chunk.kind}, grid ${chunk.gridIndex}, LOD ${chunk.lod}) ends at ${chunk.offset + chunk.length}, ` +
72
+ `past the data section (${dataLength} bytes)`);
73
+ }
74
+ }
75
+ }
76
+ if (opts.strictChunkOrder)
77
+ checkChunkOrder(header, opts.fileLength !== undefined ? opts.fileLength - dataStart : undefined);
78
+ return { header, version, dataStart };
79
+ }
80
+ const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
81
+ const isUint = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0;
82
+ const isNum = (v) => typeof v === "number" && Number.isFinite(v);
83
+ function fail(path, what) {
84
+ throw new WvdbFormatError(`header ${path}: ${what}`);
85
+ }
86
+ function checkBox(v, path) {
87
+ if (v === null)
88
+ return;
89
+ if (!Array.isArray(v) || v.length !== 2 || !v.every((c) => Array.isArray(c) && c.length === 3 && c.every(isNum))) {
90
+ fail(path, "must be [[minX, minY, minZ], [maxX, maxY, maxZ]] or null");
91
+ }
92
+ }
93
+ function checkChunkRef(v, path, countKey) {
94
+ if (!isObject(v) || !isUint(v.offset) || !isUint(v.length))
95
+ fail(path, "must be { offset, length } of non-negative integers");
96
+ if (countKey && (!isUint(v[countKey]) || v[countKey] < 1))
97
+ fail(`${path}.${countKey}`, "must be an integer >= 1");
98
+ }
99
+ function validateHeader(h, version, opts) {
100
+ const maxVoxels = opts.maxVoxels ?? DEFAULT_MAX_VOXELS;
101
+ if (!isObject(h))
102
+ fail("", "must be a JSON object");
103
+ if (h.version !== version)
104
+ fail(".version", `must equal the preamble version ${version} (got ${String(h.version)})`);
105
+ if (!isObject(h.source) || typeof h.source.file !== "string" || typeof h.source.sha256 !== "string") {
106
+ fail(".source", "must be { file: string, sha256: string }");
107
+ }
108
+ if (h.brickDim !== WVDB_BRICK_DIM)
109
+ fail(".brickDim", `must be 8 (got ${String(h.brickDim)})`);
110
+ const bake = h.bake;
111
+ if (!isObject(bake))
112
+ fail(".bake", "must be an object");
113
+ if (bake.bits !== 8 && bake.bits !== 16)
114
+ fail(".bake.bits", "must be 8 or 16");
115
+ if (!isUint(bake.lods) || bake.lods < 1)
116
+ fail(".bake.lods", "must be an integer >= 1");
117
+ if (!Array.isArray(h.grids))
118
+ fail(".grids", "must be an array");
119
+ const lods = bake.lods;
120
+ const names = new Set();
121
+ h.grids.forEach((g, gi) => {
122
+ const p = `.grids[${gi}]`;
123
+ if (!isObject(g))
124
+ fail(p, "must be an object");
125
+ if (typeof g.name !== "string")
126
+ fail(`${p}.name`, "must be a string");
127
+ if (names.has(g.name))
128
+ fail(`${p}.name`, `"${g.name}" is not unique`);
129
+ names.add(g.name);
130
+ if (typeof g.class !== "string")
131
+ fail(`${p}.class`, "must be a string");
132
+ if (!Array.isArray(g.lods) || g.lods.length !== lods)
133
+ fail(`${p}.lods`, `must have bake.lods (${lods}) entries`);
134
+ checkBox(g.bbox, `${p}.bbox`);
135
+ const type = g.type ?? "volume";
136
+ if (type === "points") {
137
+ if (version < WVDB_POINTS_VERSION)
138
+ fail(`${p}.type`, "points grids need file version 2");
139
+ if (!isUint(g.count))
140
+ fail(`${p}.count`, "must be a non-negative integer");
141
+ if (typeof g.colors !== "boolean")
142
+ fail(`${p}.colors`, "must be a boolean");
143
+ let total = 0;
144
+ g.lods.forEach((lod, li) => {
145
+ const lp = `${p}.lods[${li}]`;
146
+ if (!isObject(lod) || !isUint(lod.points) || !Array.isArray(lod.pages))
147
+ fail(lp, "must be { points, pages[] }");
148
+ let sum = 0;
149
+ lod.pages.forEach((page, pi) => {
150
+ checkChunkRef(page, `${lp}.pages[${pi}]`, "points");
151
+ sum += page.points;
152
+ });
153
+ if (sum !== lod.points)
154
+ fail(`${lp}.points`, `${lod.points} does not equal the sum of its pages (${sum})`);
155
+ total += sum;
156
+ });
157
+ if (total !== g.count)
158
+ fail(`${p}.count`, `${g.count} does not equal the sum of points of all LODs (${total})`);
159
+ return;
160
+ }
161
+ if (type !== "volume")
162
+ fail(`${p}.type`, `unknown grid type "${String(type)}"`);
163
+ const channels = g.channels ?? 1;
164
+ if (channels !== 1 && channels !== 3)
165
+ fail(`${p}.channels`, "must be 1 or 3");
166
+ if (channels === 1 ? !isNum(g.background) : !(Array.isArray(g.background) && g.background.length === 3 && g.background.every(isNum))) {
167
+ fail(`${p}.background`, channels === 1 ? "must be a number" : "must be an array of 3 numbers");
168
+ }
169
+ g.lods.forEach((lod, li) => {
170
+ const lp = `${p}.lods[${li}]`;
171
+ if (!isObject(lod))
172
+ fail(lp, "must be an object");
173
+ const dims = lod.dimensions;
174
+ if (!Array.isArray(dims) || dims.length !== 3 || !dims.every((d) => isUint(d) && d >= 1)) {
175
+ fail(`${lp}.dimensions`, "must be 3 integers >= 1");
176
+ }
177
+ const voxels = dims[0] * dims[1] * dims[2] * channels;
178
+ if (voxels > maxVoxels)
179
+ fail(`${lp}.dimensions`, `${voxels} values is more than maxVoxels (${maxVoxels})`);
180
+ if (!isUint(lod.bricks))
181
+ fail(`${lp}.bricks`, "must be a non-negative integer");
182
+ if (!Array.isArray(lod.pages))
183
+ fail(`${lp}.pages`, "must be an array");
184
+ if (lod.mask !== undefined)
185
+ checkChunkRef(lod.mask, `${lp}.mask`);
186
+ let sum = 0;
187
+ lod.pages.forEach((page, pi) => {
188
+ checkChunkRef(page, `${lp}.pages[${pi}]`, "bricks");
189
+ sum += page.bricks;
190
+ });
191
+ if (sum !== lod.bricks)
192
+ fail(`${lp}.bricks`, `${lod.bricks} does not equal the sum of its pages (${sum})`);
193
+ const total = brickTotal(dims);
194
+ if (lod.mask === undefined && lod.bricks !== total) {
195
+ fail(`${lp}.bricks`, `a dense LOD stores all ${total} bricks (got ${lod.bricks})`);
196
+ }
197
+ if (lod.bricks > total)
198
+ fail(`${lp}.bricks`, `${lod.bricks} is more than brickTotal ${total}`);
199
+ });
200
+ });
201
+ return h;
202
+ }
203
+ /** All chunks in §9 writer order (LOD, then grid, then mask, then pages). */
204
+ export function wvdbChunks(header) {
205
+ const out = [];
206
+ const lods = header.bake.lods;
207
+ const firstPoint = header.grids.map(() => 0);
208
+ for (let lod = 0; lod < lods; lod++) {
209
+ header.grids.forEach((grid, gridIndex) => {
210
+ if (isPointsGridHeader(grid)) {
211
+ for (const page of grid.lods[lod].pages) {
212
+ out.push({ gridIndex, lod, kind: "points", offset: page.offset, length: page.length, count: page.points, first: firstPoint[gridIndex] });
213
+ firstPoint[gridIndex] += page.points;
214
+ }
215
+ return;
216
+ }
217
+ const entry = grid.lods[lod];
218
+ if (entry.mask)
219
+ out.push({ gridIndex, lod, kind: "mask", offset: entry.mask.offset, length: entry.mask.length, count: 0, first: 0 });
220
+ let first = 0;
221
+ for (const page of entry.pages) {
222
+ out.push({ gridIndex, lod, kind: "page", offset: page.offset, length: page.length, count: page.bricks, first });
223
+ first += page.bricks;
224
+ }
225
+ });
226
+ }
227
+ return out;
228
+ }
229
+ function checkChunkOrder(header, dataLength) {
230
+ let end = 0;
231
+ for (const c of wvdbChunks(header)) {
232
+ if (c.offset !== end) {
233
+ throw new WvdbFormatError(`§9 chunk order: ${c.kind} of grid ${c.gridIndex} LOD ${c.lod} is at ${c.offset}, expected ${end}`);
234
+ }
235
+ end += c.length;
236
+ }
237
+ if (dataLength !== undefined && end !== dataLength) {
238
+ throw new WvdbFormatError(`§9 chunk order: chunks end at ${end} but the data section has ${dataLength} bytes`);
239
+ }
240
+ }
241
+ /**
242
+ * Absolute file byte range `[start, end)` that holds the chunks of `lod` for
243
+ * all grids (one contiguous range in a conforming file, §9). `start === end`
244
+ * when the LOD has no chunks.
245
+ * @param info The parsed header.
246
+ * @param lod LOD index (0 is the coarsest).
247
+ */
248
+ export function wvdbLodByteRange(info, lod) {
249
+ checkLodIndex(info.header, lod);
250
+ let start = Infinity;
251
+ let end = -Infinity;
252
+ for (const c of wvdbChunks(info.header)) {
253
+ if (c.lod !== lod)
254
+ continue;
255
+ start = Math.min(start, c.offset);
256
+ end = Math.max(end, c.offset + c.length);
257
+ }
258
+ if (start === Infinity) {
259
+ const at = lod === 0 ? info.dataStart : wvdbPrefixLength(info, lod - 1);
260
+ return { start: at, end: at };
261
+ }
262
+ return { start: info.dataStart + start, end: info.dataStart + end };
263
+ }
264
+ /**
265
+ * Bytes from the start of the file needed to decode LODs 0..lod (header included).
266
+ * @param info The parsed header.
267
+ * @param lod The last LOD to decode.
268
+ */
269
+ export function wvdbPrefixLength(info, lod) {
270
+ checkLodIndex(info.header, lod);
271
+ let end = 0;
272
+ for (const c of wvdbChunks(info.header))
273
+ if (c.lod <= lod)
274
+ end = Math.max(end, c.offset + c.length);
275
+ return info.dataStart + end;
276
+ }
277
+ function checkLodIndex(header, lod) {
278
+ if (!Number.isInteger(lod) || lod < 0 || lod >= header.bake.lods) {
279
+ throw new VDBToolsError("VDB_BAD_OPTION", `wvdb: LOD ${lod} is out of range (0..${header.bake.lods - 1})`);
280
+ }
281
+ }
282
+ /** Inflates one zlib chunk, stopping past `maxSize` bytes (§14). */
283
+ export function inflateWvdbChunk(bytes, maxSize) {
284
+ const out = new Uint8Array(maxSize + 1);
285
+ let result;
286
+ try {
287
+ result = unzlibSync(bytes, { out });
288
+ }
289
+ catch (err) {
290
+ throw new WvdbFormatError(`chunk does not inflate: ${err.message}`);
291
+ }
292
+ if (result.byteLength > maxSize)
293
+ throw new WvdbFormatError(`chunk inflates past its size limit (${maxSize} bytes)`);
294
+ return result;
295
+ }
296
+ const backgroundOf = (grid) => typeof grid.background === "number" ? [grid.background] : [...grid.background];
297
+ function sliceChunk(bytes, byteOffset, info, c) {
298
+ const start = info.dataStart + c.offset - byteOffset;
299
+ const end = start + c.length;
300
+ if (start < 0 || end > bytes.byteLength) {
301
+ throw new WvdbFormatError(`chunk (${c.kind}, grid ${c.gridIndex}, LOD ${c.lod}) at file bytes ${start + byteOffset}..${end + byteOffset} ` +
302
+ `is not inside the given bytes (${byteOffset}..${byteOffset + bytes.byteLength})`);
303
+ }
304
+ return bytes.subarray(start, end);
305
+ }
306
+ /**
307
+ * Decodes LOD `lod` of every grid. `bytes` holds file bytes starting at file
308
+ * offset `byteOffset` (0 for the whole file or a prefix; `range.start` for a
309
+ * range read from `wvdbLodByteRange`). Returns one level per grid, in header
310
+ * order.
311
+ * @param info The parsed header.
312
+ * @param lod The LOD to decode.
313
+ * @param bytes File bytes holding every chunk of that LOD.
314
+ * @param byteOffset File offset of `bytes[0]`.
315
+ */
316
+ export function decodeWvdbLod(info, lod, bytes, byteOffset = 0) {
317
+ checkLodIndex(info.header, lod);
318
+ const chunks = wvdbChunks(info.header).filter((c) => c.lod === lod);
319
+ const decoders = lodDecoders(info, lod);
320
+ for (const c of chunks)
321
+ decoders[c.gridIndex].add(c, sliceChunk(bytes, byteOffset, info, c));
322
+ return decoders.map((d) => d.finish());
323
+ }
324
+ function lodDecoders(info, lod) {
325
+ const bits = info.header.bake.bits;
326
+ return info.header.grids.map((grid) => isPointsGridHeader(grid) ? pointsLodDecoder(grid, lod) : volumeLodDecoder(grid, lod, bits));
327
+ }
328
+ function volumeLodDecoder(grid, lod, bits) {
329
+ const entry = grid.lods[lod];
330
+ const channels = (grid.channels ?? 1);
331
+ const dimensions = [...entry.dimensions];
332
+ const [X, Y, Z] = dimensions;
333
+ const total = brickTotal(dimensions);
334
+ const layout = entry.mask ? "sparse" : "dense";
335
+ const sparse = layout === "sparse";
336
+ const background = backgroundOf(grid);
337
+ const plane = X * Y * Z;
338
+ const values = new Float32Array(plane * channels);
339
+ for (let c = 0; c < channels; c++)
340
+ values.fill(background[c], c * plane, (c + 1) * plane);
341
+ const level = {
342
+ kind: "volume",
343
+ lod,
344
+ dimensions,
345
+ layout,
346
+ channels,
347
+ brickCounts: brickCounts(dimensions),
348
+ brickTotal: total,
349
+ mask: null,
350
+ brickIndices: new Uint32Array(entry.bricks),
351
+ mins: new Float32Array(entry.bricks * channels),
352
+ maxs: new Float32Array(entry.bricks * channels),
353
+ values,
354
+ bricksDecoded: 0,
355
+ decoded: new Uint32Array(Math.ceil(total / 32)),
356
+ };
357
+ const seen = level.decoded;
358
+ let masks = 0;
359
+ return {
360
+ level,
361
+ add(c, raw) {
362
+ if (c.kind === "mask") {
363
+ if (masks++ > 0)
364
+ throw new WvdbFormatError(`LOD ${lod} of "${grid.name}": more than one mask chunk`);
365
+ level.mask = decodeMask(inflateWvdbChunk(raw, maskByteSize(total)), total);
366
+ return;
367
+ }
368
+ const maxSize = pageByteSize(c.count, channels, bits, sparse, c.count * channels);
369
+ const page = decodePage(inflateWvdbChunk(raw, maxSize), {
370
+ layout,
371
+ bits,
372
+ channels,
373
+ count: c.count,
374
+ firstIndex: c.first,
375
+ brickTotal: total,
376
+ });
377
+ // `c.first` is the page's position in the LOD's file order, whatever order pages decode in.
378
+ level.brickIndices.set(page.indices, c.first);
379
+ level.mins.set(page.mins, c.first * channels);
380
+ level.maxs.set(page.maxs, c.first * channels);
381
+ level.bricksDecoded += c.count;
382
+ for (let b = 0; b < page.indices.length; b++) {
383
+ const index = page.indices[b];
384
+ if (isMaskBitSet(seen, index))
385
+ throw new WvdbFormatError(`LOD ${lod} of "${grid.name}": brick ${index} is stored twice`);
386
+ seen[index >>> 5] |= 1 << (index & 31);
387
+ const [ox, oy, oz] = brickOrigin(dimensions, index);
388
+ const nx = Math.min(WVDB_BRICK_DIM, X - ox);
389
+ const ny = Math.min(WVDB_BRICK_DIM, Y - oy);
390
+ const nz = Math.min(WVDB_BRICK_DIM, Z - oz);
391
+ for (let ch = 0; ch < channels; ch++) {
392
+ const src = (b * channels + ch) * WVDB_BRICK_VOXELS;
393
+ const dst = ch * plane;
394
+ for (let k = 0; k < nz; k++) {
395
+ for (let j = 0; j < ny; j++) {
396
+ const row = dst + ox + (oy + j) * X + (oz + k) * X * Y;
397
+ const from = src + WVDB_BRICK_DIM * j + 64 * k;
398
+ for (let i = 0; i < nx; i++)
399
+ values[row + i] = page.values[from + i];
400
+ }
401
+ }
402
+ }
403
+ }
404
+ },
405
+ finish() {
406
+ if (sparse) {
407
+ const mask = level.mask;
408
+ if (!mask)
409
+ throw new WvdbFormatError(`LOD ${lod} of "${grid.name}": sparse LOD without a mask chunk`);
410
+ for (let w = 0; w < mask.length; w++) {
411
+ if (mask[w] !== seen[w]) {
412
+ throw new WvdbFormatError(`LOD ${lod} of "${grid.name}": the mask does not match the stored brick indices (§6.3)`);
413
+ }
414
+ }
415
+ }
416
+ return level;
417
+ },
418
+ };
419
+ }
420
+ function pointsLodDecoder(grid, lod) {
421
+ const count = grid.lods[lod].points;
422
+ // Stored index of this LOD's first point: the points of the coarser LODs (§3.5; equals wvdbChunks' `first`).
423
+ const firstPoint = grid.lods.slice(0, lod).reduce((s, l) => s + l.points, 0);
424
+ const level = {
425
+ kind: "points",
426
+ lod,
427
+ firstPoint,
428
+ count,
429
+ positions: new Float32Array(count * 3),
430
+ colors: grid.colors ? new Float32Array(count * 3) : null,
431
+ pointsDecoded: 0,
432
+ };
433
+ return {
434
+ level,
435
+ add(c, raw) {
436
+ const decoded = decodePoints(inflateWvdbChunk(raw, pointsChunkByteSize(c.count, grid.colors)), {
437
+ count: c.count,
438
+ colors: grid.colors,
439
+ });
440
+ const at = c.first - firstPoint;
441
+ level.positions.set(decoded.positions, at * 3);
442
+ if (level.colors && decoded.colors)
443
+ level.colors.set(decoded.colors, at * 3);
444
+ level.pointsDecoded += c.count;
445
+ },
446
+ finish: () => level,
447
+ };
448
+ }
449
+ function makeGrids(header) {
450
+ return header.grids.map((g) => {
451
+ if (isPointsGridHeader(g)) {
452
+ return {
453
+ kind: "points",
454
+ name: g.name,
455
+ class: normalizeWvdbClass(g.class),
456
+ bbox: g.bbox,
457
+ count: g.count,
458
+ ...(g.sourceCount !== undefined ? { sourceCount: g.sourceCount } : {}),
459
+ ...(g.spacing !== undefined ? { spacing: g.spacing } : {}),
460
+ colors: g.colors,
461
+ header: g,
462
+ levels: [],
463
+ };
464
+ }
465
+ return {
466
+ kind: "volume",
467
+ name: g.name,
468
+ class: normalizeWvdbClass(g.class),
469
+ bbox: g.bbox,
470
+ channels: (g.channels ?? 1),
471
+ background: backgroundOf(g),
472
+ ...(g.meanDensity !== undefined ? { meanDensity: g.meanDensity } : {}),
473
+ ...(g.nonZeroVoxels !== undefined ? { nonZeroVoxels: g.nonZeroVoxels } : {}),
474
+ header: g,
475
+ levels: [],
476
+ };
477
+ });
478
+ }
479
+ function addLevels(grids, levels) {
480
+ levels.forEach((level, i) => grids[i].levels.push(level));
481
+ }
482
+ /**
483
+ * Reads a `.wvdb` file (or, with `partial`, a prefix of one) and decodes its
484
+ * LODs coarse to fine.
485
+ * @param input The file's bytes (or a prefix with `partial`).
486
+ * @param opts LOD cap, prefix mode and header limits.
487
+ */
488
+ export function readWvdb(input, opts = {}) {
489
+ const bytes = input instanceof Uint8Array ? input : new Uint8Array(input);
490
+ const { maxLod, partial = false, ...headerOpts } = opts;
491
+ const info = readWvdbHeader(bytes, partial ? headerOpts : { ...headerOpts, fileLength: bytes.byteLength });
492
+ if (!info)
493
+ throw new WvdbFormatError(`only ${bytes.byteLength} bytes: the header is incomplete`);
494
+ const { header } = info;
495
+ const grids = makeGrids(header);
496
+ const last = Math.min(header.bake.lods - 1, maxLod ?? Infinity);
497
+ let decoded = 0;
498
+ for (let lod = 0; lod <= last; lod++) {
499
+ if (partial && wvdbPrefixLength(info, lod) > bytes.byteLength)
500
+ break;
501
+ addLevels(grids, decodeWvdbLod(info, lod, bytes, 0));
502
+ decoded++;
503
+ }
504
+ return {
505
+ version: info.version,
506
+ header,
507
+ dataStart: info.dataStart,
508
+ source: header.source,
509
+ bake: header.bake,
510
+ grids,
511
+ lodsDecoded: decoded,
512
+ complete: decoded === header.bake.lods,
513
+ };
514
+ }
515
+ const DEFAULT_MAX_HEADER_BYTES = 16 * 1024 * 1024;
516
+ /**
517
+ * Largest compressed size accepted for a chunk that inflates to at most `n`
518
+ * bytes: zlib's `compressBound` is about `n + n/4096 + 13`; this allows
519
+ * `n + n/1024 + 1 KiB`, which any deflate encoder's output fits (stored blocks
520
+ * cost 5 bytes per 64 KiB). The stream reader holds one chunk's bytes at a
521
+ * time, so this is its memory bound.
522
+ */
523
+ export function wvdbChunkByteLimit(inflatedBytes) {
524
+ return inflatedBytes + Math.ceil(inflatedBytes / 1024) + 1024;
525
+ }
526
+ function inflatedLimit(header, c) {
527
+ const grid = header.grids[c.gridIndex];
528
+ if (isPointsGridHeader(grid))
529
+ return pointsChunkByteSize(c.count, grid.colors);
530
+ const entry = grid.lods[c.lod];
531
+ const total = brickTotal(entry.dimensions);
532
+ if (c.kind === "mask")
533
+ return maskByteSize(total);
534
+ const channels = grid.channels ?? 1;
535
+ return pageByteSize(c.count, channels, header.bake.bits, entry.mask !== undefined, c.count * channels);
536
+ }
537
+ /**
538
+ * Push-style coarse-first decoder for a `.wvdb` download: feed it the bytes
539
+ * as they arrive; each `push` returns the LODs that became complete (and,
540
+ * with `partialLods`, the LODs that gained a page).
541
+ *
542
+ * const reader = new WvdbStreamReader({ partialLods: true });
543
+ * for await (const chunk of response.body) for (const e of reader.push(chunk)) show(e);
544
+ * reader.end();
545
+ *
546
+ * Chunks are decoded one at a time, in file order, as soon as their last byte
547
+ * arrives, so the reader holds at most one chunk's compressed bytes (plus the
548
+ * header until it parses) besides the decoded LODs: `peakBufferedBytes` is
549
+ * bounded by the largest chunk plus one pushed buffer. Each chunk's length is
550
+ * checked against {@link wvdbChunkByteLimit} when the header arrives. After an
551
+ * error, every later call throws the same error.
552
+
553
+ */
554
+ export class WvdbStreamReader {
555
+ opts;
556
+ buf = new Uint8Array(0);
557
+ /** Absolute file offset of `buf[0]`, and one past the last byte held. */
558
+ bufStart = 0;
559
+ bufEnd = 0;
560
+ received = 0;
561
+ next = 0;
562
+ finalLod = 0;
563
+ chunks = [];
564
+ ci = 0;
565
+ remaining = [];
566
+ decoders = new Map();
567
+ failure = null;
568
+ peak = 0;
569
+ /** The parsed header, or null before it has arrived. */
570
+ info = null;
571
+ /** The decoded file so far (grids gain levels as LODs complete); null before the header. */
572
+ file = null;
573
+ /** @param opts LOD cap, partial-LOD events and header limits. */
574
+ constructor(opts = {}) {
575
+ this.opts = opts;
576
+ }
577
+ /** The parsed JSON header, or null before it has arrived. */
578
+ get header() {
579
+ return this.info?.header ?? null;
580
+ }
581
+ /** True when every LOD up to `maxLod` is decoded. */
582
+ get done() {
583
+ return this.info !== null && this.next > this.finalLod;
584
+ }
585
+ /** File bytes needed to finish (header known), or null before the header. */
586
+ get bytesTotal() {
587
+ return this.info ? wvdbPrefixLength(this.info, this.finalLod) : null;
588
+ }
589
+ /** File bytes pushed so far. */
590
+ get bytesReceived() {
591
+ return this.received;
592
+ }
593
+ /** Compressed bytes held now, and the most ever held. */
594
+ get bufferedBytes() {
595
+ return this.bufEnd - this.bufStart;
596
+ }
597
+ /** The most compressed bytes the reader has held at once. */
598
+ get peakBufferedBytes() {
599
+ return this.peak;
600
+ }
601
+ /**
602
+ * Feeds the next bytes of the download and decodes what they complete.
603
+ * @param chunk The next bytes, in file order.
604
+ * @returns The LOD events this push produced (possibly none).
605
+ */
606
+ push(chunk) {
607
+ if (this.failure !== null)
608
+ throw this.failure;
609
+ if (this.done)
610
+ return [];
611
+ try {
612
+ this.append(chunk);
613
+ const events = [];
614
+ if (!this.info && !this.readHeader())
615
+ return events;
616
+ this.completeLods(events);
617
+ this.decodeChunks(events);
618
+ if (this.done) {
619
+ this.buf = new Uint8Array(0);
620
+ this.bufStart = this.bufEnd = this.received;
621
+ }
622
+ return events;
623
+ }
624
+ catch (err) {
625
+ this.failure = err;
626
+ this.buf = new Uint8Array(0);
627
+ throw err;
628
+ }
629
+ }
630
+ /** Call when the stream ends: throws `WvdbFormatError` if a LOD up to `maxLod` is still missing. */
631
+ end() {
632
+ if (this.failure !== null)
633
+ throw this.failure;
634
+ if (this.done)
635
+ return;
636
+ this.failure = new WvdbFormatError(this.info
637
+ ? `stream ended at byte ${this.received} before LOD ${this.next} was complete (needs ${this.bytesTotal} bytes)`
638
+ : `stream ended at byte ${this.received} before the header was complete`);
639
+ throw this.failure;
640
+ }
641
+ /** Absolute offset below which no byte is needed any more. */
642
+ keepFrom() {
643
+ if (!this.info)
644
+ return 0;
645
+ const c = this.chunks[this.ci];
646
+ return c ? this.info.dataStart + c.offset : Infinity;
647
+ }
648
+ /** Drops held bytes before `keepFrom()`. */
649
+ compact() {
650
+ const keep = this.keepFrom();
651
+ if (keep <= this.bufStart)
652
+ return;
653
+ const drop = Math.min(keep, this.bufEnd) - this.bufStart;
654
+ if (drop > 0) {
655
+ this.buf.copyWithin(0, drop, this.bufEnd - this.bufStart);
656
+ this.bufStart += drop;
657
+ }
658
+ }
659
+ append(chunk) {
660
+ const absStart = this.received;
661
+ const absEnd = absStart + chunk.byteLength;
662
+ this.received = absEnd;
663
+ this.compact();
664
+ // Before the header, everything is kept (readHeader caps its length); after it, only up to the last needed chunk.
665
+ const from = Math.max(absStart, this.keepFrom());
666
+ const to = Math.min(absEnd, this.info ? this.bytesTotal : Infinity);
667
+ if (to <= from)
668
+ return;
669
+ // Held bytes end at absStart, or are all before keepFrom (then none are held): restart the buffer at `from`.
670
+ if (this.bufEnd !== from)
671
+ this.bufStart = this.bufEnd = from;
672
+ const held = this.bufEnd - this.bufStart;
673
+ const need = held + (to - from);
674
+ if (need > this.buf.byteLength) {
675
+ const grown = new Uint8Array(Math.max(need, Math.min(this.buf.byteLength * 2, need + (1 << 20))));
676
+ grown.set(this.buf.subarray(0, held));
677
+ this.buf = grown;
678
+ }
679
+ this.buf.set(chunk.subarray(from - absStart, to - absStart), held);
680
+ this.bufEnd = to;
681
+ this.peak = Math.max(this.peak, this.bufEnd - this.bufStart);
682
+ }
683
+ readHeader() {
684
+ // Before the header nothing is dropped, so the buffer starts at file offset 0.
685
+ const held = this.buf.subarray(0, this.bufEnd - this.bufStart);
686
+ if (held.byteLength >= WVDB_PREAMBLE_SIZE) {
687
+ const headerLength = new DataView(held.buffer, held.byteOffset).getUint32(8, true);
688
+ const max = this.opts.maxHeaderBytes ?? DEFAULT_MAX_HEADER_BYTES;
689
+ if (headerLength > max)
690
+ throw new WvdbFormatError(`headerLength ${headerLength} is more than maxHeaderBytes (${max})`);
691
+ }
692
+ const { maxLod, partialLods: _p, maxHeaderBytes: _m, ...headerOpts } = this.opts;
693
+ const info = readWvdbHeader(held, headerOpts);
694
+ if (!info)
695
+ return false;
696
+ const { header } = info;
697
+ this.finalLod = Math.min(header.bake.lods - 1, maxLod ?? Infinity);
698
+ const chunks = wvdbChunks(header).filter((c) => c.lod <= this.finalLod);
699
+ for (const c of chunks) {
700
+ const limit = wvdbChunkByteLimit(inflatedLimit(header, c));
701
+ if (c.length > limit) {
702
+ throw new WvdbFormatError(`chunk (${c.kind}, grid ${c.gridIndex}, LOD ${c.lod}) is ${c.length} bytes, more than a deflate of its ` +
703
+ `${inflatedLimit(header, c)}-byte content can be (${limit})`);
704
+ }
705
+ }
706
+ // File order; a stable sort keeps §9 order for equal offsets.
707
+ this.chunks = chunks.map((c, i) => ({ c, i })).sort((a, b) => a.c.offset - b.c.offset || a.i - b.i).map(({ c }) => c);
708
+ this.remaining = Array.from({ length: this.finalLod + 1 }, () => 0);
709
+ for (const c of this.chunks)
710
+ this.remaining[c.lod]++;
711
+ this.info = info;
712
+ this.file = {
713
+ version: info.version,
714
+ header,
715
+ dataStart: info.dataStart,
716
+ source: header.source,
717
+ bake: header.bake,
718
+ grids: makeGrids(header),
719
+ lodsDecoded: 0,
720
+ complete: false,
721
+ };
722
+ return true;
723
+ }
724
+ decodersFor(lod) {
725
+ let d = this.decoders.get(lod);
726
+ if (!d) {
727
+ d = lodDecoders(this.info, lod);
728
+ this.decoders.set(lod, d);
729
+ }
730
+ return d;
731
+ }
732
+ decodeChunks(events) {
733
+ const info = this.info;
734
+ while (this.ci < this.chunks.length) {
735
+ const c = this.chunks[this.ci];
736
+ const start = info.dataStart + c.offset;
737
+ const end = start + c.length;
738
+ if (end > this.bufEnd)
739
+ break;
740
+ if (start < this.bufStart)
741
+ throw new Error("WvdbStreamReader: internal error, chunk bytes were dropped");
742
+ const decoders = this.decodersFor(c.lod);
743
+ decoders[c.gridIndex].add(c, this.buf.subarray(start - this.bufStart, end - this.bufStart));
744
+ this.ci++;
745
+ this.remaining[c.lod]--;
746
+ if (this.opts.partialLods)
747
+ events.push({ lod: c.lod, levels: decoders.map((d) => d.level), complete: false, chunk: c });
748
+ this.completeLods(events);
749
+ }
750
+ // Release bytes before the next chunk now (the next push would too).
751
+ this.compact();
752
+ }
753
+ completeLods(events) {
754
+ while (this.next <= this.finalLod && this.remaining[this.next] === 0) {
755
+ const lod = this.next;
756
+ const levels = this.decodersFor(lod).map((d) => d.finish());
757
+ this.decoders.delete(lod);
758
+ addLevels(this.file.grids, levels);
759
+ this.file.lodsDecoded = lod + 1;
760
+ this.file.complete = lod + 1 === this.info.header.bake.lods;
761
+ events.push({ lod, levels, complete: true });
762
+ this.next++;
763
+ }
764
+ }
765
+ }
766
+ //# sourceMappingURL=read.js.map