@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.
- package/CHANGELOG.md +727 -0
- package/LICENSE +21 -0
- package/README.md +496 -2
- package/THIRD_PARTY_NOTICES.md +315 -0
- package/dist/core/compute/atlas.d.ts +102 -0
- package/dist/core/compute/atlas.js +103 -0
- package/dist/core/compute/atlas.js.map +1 -0
- package/dist/core/compute/index.d.ts +13 -0
- package/dist/core/compute/index.js +9 -0
- package/dist/core/compute/index.js.map +1 -0
- package/dist/core/compute/majorant-build.d.ts +45 -0
- package/dist/core/compute/majorant-build.js +193 -0
- package/dist/core/compute/majorant-build.js.map +1 -0
- package/dist/core/compute/multi-scale.d.ts +155 -0
- package/dist/core/compute/multi-scale.js +684 -0
- package/dist/core/compute/multi-scale.js.map +1 -0
- package/dist/core/compute/pyramid.d.ts +120 -0
- package/dist/core/compute/pyramid.js +468 -0
- package/dist/core/compute/pyramid.js.map +1 -0
- package/dist/core/compute/shared.d.ts +116 -0
- package/dist/core/compute/shared.js +211 -0
- package/dist/core/compute/shared.js.map +1 -0
- package/dist/core/compute/stats.d.ts +78 -0
- package/dist/core/compute/stats.js +193 -0
- package/dist/core/compute/stats.js.map +1 -0
- package/dist/core/compute/value-transform.d.ts +30 -0
- package/dist/core/compute/value-transform.js +64 -0
- package/dist/core/compute/value-transform.js.map +1 -0
- package/dist/core/errors.d.ts +21 -0
- package/dist/core/errors.js +17 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/frame/emission.d.ts +85 -0
- package/dist/core/frame/emission.js +422 -0
- package/dist/core/frame/emission.js.map +1 -0
- package/dist/core/frame/environment.d.ts +47 -0
- package/dist/core/frame/environment.js +178 -0
- package/dist/core/frame/environment.js.map +1 -0
- package/dist/core/frame/index.d.ts +39 -0
- package/dist/core/frame/index.js +27 -0
- package/dist/core/frame/index.js.map +1 -0
- package/dist/core/frame/kernels.d.ts +115 -0
- package/dist/core/frame/kernels.js +496 -0
- package/dist/core/frame/kernels.js.map +1 -0
- package/dist/core/frame/limits.d.ts +67 -0
- package/dist/core/frame/limits.js +109 -0
- package/dist/core/frame/limits.js.map +1 -0
- package/dist/core/frame/phase.d.ts +17 -0
- package/dist/core/frame/phase.js +53 -0
- package/dist/core/frame/phase.js.map +1 -0
- package/dist/core/frame/pipelines.d.ts +49 -0
- package/dist/core/frame/pipelines.js +147 -0
- package/dist/core/frame/pipelines.js.map +1 -0
- package/dist/core/frame/renderer.d.ts +122 -0
- package/dist/core/frame/renderer.js +1712 -0
- package/dist/core/frame/renderer.js.map +1 -0
- package/dist/core/frame/resources.d.ts +71 -0
- package/dist/core/frame/resources.js +100 -0
- package/dist/core/frame/resources.js.map +1 -0
- package/dist/core/frame/scattering.d.ts +97 -0
- package/dist/core/frame/scattering.js +332 -0
- package/dist/core/frame/scattering.js.map +1 -0
- package/dist/core/frame/settings.d.ts +243 -0
- package/dist/core/frame/settings.js +67 -0
- package/dist/core/frame/settings.js.map +1 -0
- package/dist/core/frame/shadows.d.ts +55 -0
- package/dist/core/frame/shadows.js +460 -0
- package/dist/core/frame/shadows.js.map +1 -0
- package/dist/core/frame/types.d.ts +415 -0
- package/dist/core/frame/types.js +49 -0
- package/dist/core/frame/types.js.map +1 -0
- package/dist/core/frame/uniforms.d.ts +105 -0
- package/dist/core/frame/uniforms.js +276 -0
- package/dist/core/frame/uniforms.js.map +1 -0
- package/dist/core/frame/wgsl/chunks.d.ts +4 -0
- package/dist/core/frame/wgsl/chunks.js +728 -0
- package/dist/core/frame/wgsl/chunks.js.map +1 -0
- package/dist/core/frame/wgsl/emission.d.ts +82 -0
- package/dist/core/frame/wgsl/emission.js +353 -0
- package/dist/core/frame/wgsl/emission.js.map +1 -0
- package/dist/core/frame/wgsl/environment.d.ts +42 -0
- package/dist/core/frame/wgsl/environment.js +711 -0
- package/dist/core/frame/wgsl/environment.js.map +1 -0
- package/dist/core/frame/wgsl/gather.d.ts +55 -0
- package/dist/core/frame/wgsl/gather.js +850 -0
- package/dist/core/frame/wgsl/gather.js.map +1 -0
- package/dist/core/frame/wgsl/integrate.d.ts +78 -0
- package/dist/core/frame/wgsl/integrate.js +213 -0
- package/dist/core/frame/wgsl/integrate.js.map +1 -0
- package/dist/core/frame/wgsl/lighting.d.ts +103 -0
- package/dist/core/frame/wgsl/lighting.js +1636 -0
- package/dist/core/frame/wgsl/lighting.js.map +1 -0
- package/dist/core/frame/wgsl/occluders.d.ts +20 -0
- package/dist/core/frame/wgsl/occluders.js +95 -0
- package/dist/core/frame/wgsl/occluders.js.map +1 -0
- package/dist/core/frame/wgsl/resolve.d.ts +19 -0
- package/dist/core/frame/wgsl/resolve.js +205 -0
- package/dist/core/frame/wgsl/resolve.js.map +1 -0
- package/dist/core/frame/wgsl/shadows.d.ts +35 -0
- package/dist/core/frame/wgsl/shadows.js +328 -0
- package/dist/core/frame/wgsl/shadows.js.map +1 -0
- package/dist/core/half.d.ts +11 -0
- package/dist/core/half.js +22 -0
- package/dist/core/half.js.map +1 -0
- package/dist/core/index.d.ts +52 -0
- package/dist/core/index.js +46 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/internal.d.ts +31 -0
- package/dist/core/internal.js +32 -0
- package/dist/core/internal.js.map +1 -0
- package/dist/core/pool/affine.d.ts +34 -0
- package/dist/core/pool/affine.js +100 -0
- package/dist/core/pool/affine.js.map +1 -0
- package/dist/core/pool/allocator.d.ts +32 -0
- package/dist/core/pool/allocator.js +81 -0
- package/dist/core/pool/allocator.js.map +1 -0
- package/dist/core/pool/image-header.d.ts +93 -0
- package/dist/core/pool/image-header.js +194 -0
- package/dist/core/pool/image-header.js.map +1 -0
- package/dist/core/pool/layout.d.ts +198 -0
- package/dist/core/pool/layout.js +316 -0
- package/dist/core/pool/layout.js.map +1 -0
- package/dist/core/pool/limits.d.ts +41 -0
- package/dist/core/pool/limits.js +80 -0
- package/dist/core/pool/limits.js.map +1 -0
- package/dist/core/pool/pool.d.ts +384 -0
- package/dist/core/pool/pool.js +1184 -0
- package/dist/core/pool/pool.js.map +1 -0
- package/dist/core/reference/index.d.ts +6 -0
- package/dist/core/reference/index.js +7 -0
- package/dist/core/reference/index.js.map +1 -0
- package/dist/core/reference/renderer.d.ts +105 -0
- package/dist/core/reference/renderer.js +474 -0
- package/dist/core/reference/renderer.js.map +1 -0
- package/dist/core/reference/wgsl.d.ts +65 -0
- package/dist/core/reference/wgsl.js +803 -0
- package/dist/core/reference/wgsl.js.map +1 -0
- package/dist/core/sequence.d.ts +347 -0
- package/dist/core/sequence.js +548 -0
- package/dist/core/sequence.js.map +1 -0
- package/dist/core/source/brick-cache.d.ts +165 -0
- package/dist/core/source/brick-cache.js +627 -0
- package/dist/core/source/brick-cache.js.map +1 -0
- package/dist/core/source/dense-fill.d.ts +53 -0
- package/dist/core/source/dense-fill.js +377 -0
- package/dist/core/source/dense-fill.js.map +1 -0
- package/dist/core/source/dense.d.ts +50 -0
- package/dist/core/source/dense.js +384 -0
- package/dist/core/source/dense.js.map +1 -0
- package/dist/core/source/sparse-wgsl.d.ts +92 -0
- package/dist/core/source/sparse-wgsl.js +481 -0
- package/dist/core/source/sparse-wgsl.js.map +1 -0
- package/dist/core/source/sparse.d.ts +192 -0
- package/dist/core/source/sparse.js +762 -0
- package/dist/core/source/sparse.js.map +1 -0
- package/dist/core/source/types.d.ts +120 -0
- package/dist/core/source/types.js +9 -0
- package/dist/core/source/types.js.map +1 -0
- package/dist/core/surface/index.d.ts +10 -0
- package/dist/core/surface/index.js +9 -0
- package/dist/core/surface/index.js.map +1 -0
- package/dist/core/surface/level-set-pass.d.ts +140 -0
- package/dist/core/surface/level-set-pass.js +291 -0
- package/dist/core/surface/level-set-pass.js.map +1 -0
- package/dist/core/surface/level-set-wgsl.d.ts +46 -0
- package/dist/core/surface/level-set-wgsl.js +99 -0
- package/dist/core/surface/level-set-wgsl.js.map +1 -0
- package/dist/core/surface/points.d.ts +109 -0
- package/dist/core/surface/points.js +226 -0
- package/dist/core/surface/points.js.map +1 -0
- package/dist/core/types.d.ts +37 -0
- package/dist/core/types.js +32 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/wgsl/api.d.ts +65 -0
- package/dist/core/wgsl/api.js +546 -0
- package/dist/core/wgsl/api.js.map +1 -0
- package/dist/core/wgsl/generate.d.ts +90 -0
- package/dist/core/wgsl/generate.js +678 -0
- package/dist/core/wgsl/generate.js.map +1 -0
- package/dist/core/wgsl/lean.d.ts +50 -0
- package/dist/core/wgsl/lean.js +327 -0
- package/dist/core/wgsl/lean.js.map +1 -0
- package/dist/core/wgsl/level-set.d.ts +58 -0
- package/dist/core/wgsl/level-set.js +200 -0
- package/dist/core/wgsl/level-set.js.map +1 -0
- package/dist/core/wgsl/majorant.d.ts +62 -0
- package/dist/core/wgsl/majorant.js +381 -0
- package/dist/core/wgsl/majorant.js.map +1 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.js +333 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
- package/dist/core/wgsl/reserved.d.ts +9 -0
- package/dist/core/wgsl/reserved.js +26 -0
- package/dist/core/wgsl/reserved.js.map +1 -0
- package/dist/core/wgsl/types.d.ts +198 -0
- package/dist/core/wgsl/types.js +2 -0
- package/dist/core/wgsl/types.js.map +1 -0
- package/dist/three/coarse-first.d.ts +207 -0
- package/dist/three/coarse-first.js +205 -0
- package/dist/three/coarse-first.js.map +1 -0
- package/dist/three/compute.d.ts +73 -0
- package/dist/three/compute.js +66 -0
- package/dist/three/compute.js.map +1 -0
- package/dist/three/device.d.ts +66 -0
- package/dist/three/device.js +62 -0
- package/dist/three/device.js.map +1 -0
- package/dist/three/frame/core-environment.d.ts +38 -0
- package/dist/three/frame/core-environment.js +154 -0
- package/dist/three/frame/core-environment.js.map +1 -0
- package/dist/three/frame/core-integrate-material.d.ts +34 -0
- package/dist/three/frame/core-integrate-material.js +162 -0
- package/dist/three/frame/core-integrate-material.js.map +1 -0
- package/dist/three/frame/core-occluders.d.ts +53 -0
- package/dist/three/frame/core-occluders.js +193 -0
- package/dist/three/frame/core-occluders.js.map +1 -0
- package/dist/three/frame/core-structs.d.ts +34 -0
- package/dist/three/frame/core-structs.js +61 -0
- package/dist/three/frame/core-structs.js.map +1 -0
- package/dist/three/frame/core-textures.d.ts +41 -0
- package/dist/three/frame/core-textures.js +114 -0
- package/dist/three/frame/core-textures.js.map +1 -0
- package/dist/three/frame/emission-light.d.ts +117 -0
- package/dist/three/frame/emission-light.js +276 -0
- package/dist/three/frame/emission-light.js.map +1 -0
- package/dist/three/frame/index.d.ts +19 -0
- package/dist/three/frame/index.js +15 -0
- package/dist/three/frame/index.js.map +1 -0
- package/dist/three/frame/medium.d.ts +33 -0
- package/dist/three/frame/medium.js +29 -0
- package/dist/three/frame/medium.js.map +1 -0
- package/dist/three/frame/renderer.d.ts +97 -0
- package/dist/three/frame/renderer.js +480 -0
- package/dist/three/frame/renderer.js.map +1 -0
- package/dist/three/frame/spectrum.d.ts +4 -0
- package/dist/three/frame/spectrum.js +15 -0
- package/dist/three/frame/spectrum.js.map +1 -0
- package/dist/three/frame/three-internals.d.ts +60 -0
- package/dist/three/frame/three-internals.js +152 -0
- package/dist/three/frame/three-internals.js.map +1 -0
- package/dist/three/frame/volume-shadows.d.ts +139 -0
- package/dist/three/frame/volume-shadows.js +403 -0
- package/dist/three/frame/volume-shadows.js.map +1 -0
- package/dist/three/frame/volume.d.ts +230 -0
- package/dist/three/frame/volume.js +268 -0
- package/dist/three/frame/volume.js.map +1 -0
- package/dist/three/grid-node.d.ts +229 -0
- package/dist/three/grid-node.js +545 -0
- package/dist/three/grid-node.js.map +1 -0
- package/dist/three/index.d.ts +52 -0
- package/dist/three/index.js +58 -0
- package/dist/three/index.js.map +1 -0
- package/dist/three/internal.d.ts +20 -0
- package/dist/three/internal.js +18 -0
- package/dist/three/internal.js.map +1 -0
- package/dist/three/level-set-material.d.ts +185 -0
- package/dist/three/level-set-material.js +241 -0
- package/dist/three/level-set-material.js.map +1 -0
- package/dist/three/level-set-physical-material.d.ts +154 -0
- package/dist/three/level-set-physical-material.js +253 -0
- package/dist/three/level-set-physical-material.js.map +1 -0
- package/dist/three/level-set-velocity.d.ts +94 -0
- package/dist/three/level-set-velocity.js +208 -0
- package/dist/three/level-set-velocity.js.map +1 -0
- package/dist/three/material.d.ts +324 -0
- package/dist/three/material.js +502 -0
- package/dist/three/material.js.map +1 -0
- package/dist/three/points.d.ts +140 -0
- package/dist/three/points.js +261 -0
- package/dist/three/points.js.map +1 -0
- package/dist/three/sparse-source.d.ts +165 -0
- package/dist/three/sparse-source.js +405 -0
- package/dist/three/sparse-source.js.map +1 -0
- package/dist/three/volume-source.d.ts +22 -0
- package/dist/three/volume-source.js +110 -0
- package/dist/three/volume-source.js.map +1 -0
- package/dist/tools/cpu/brick-atlas.d.ts +36 -0
- package/dist/tools/cpu/brick-atlas.js +129 -0
- package/dist/tools/cpu/brick-atlas.js.map +1 -0
- package/dist/tools/cpu/compute.d.ts +116 -0
- package/dist/tools/cpu/compute.js +239 -0
- package/dist/tools/cpu/compute.js.map +1 -0
- package/dist/tools/cpu/lean-reads.d.ts +81 -0
- package/dist/tools/cpu/lean-reads.js +262 -0
- package/dist/tools/cpu/lean-reads.js.map +1 -0
- package/dist/tools/cpu/level-set.d.ts +111 -0
- package/dist/tools/cpu/level-set.js +313 -0
- package/dist/tools/cpu/level-set.js.map +1 -0
- package/dist/tools/cpu/majorant.d.ts +265 -0
- package/dist/tools/cpu/majorant.js +541 -0
- package/dist/tools/cpu/majorant.js.map +1 -0
- package/dist/tools/cpu/march.d.ts +297 -0
- package/dist/tools/cpu/march.js +726 -0
- package/dist/tools/cpu/march.js.map +1 -0
- package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
- package/dist/tools/cpu/mesh-decimate.js +1225 -0
- package/dist/tools/cpu/mesh-decimate.js.map +1 -0
- package/dist/tools/cpu/points.d.ts +29 -0
- package/dist/tools/cpu/points.js +38 -0
- package/dist/tools/cpu/points.js.map +1 -0
- package/dist/tools/cpu/probe-coords.d.ts +70 -0
- package/dist/tools/cpu/probe-coords.js +116 -0
- package/dist/tools/cpu/probe-coords.js.map +1 -0
- package/dist/tools/cpu/read-value.d.ts +44 -0
- package/dist/tools/cpu/read-value.js +351 -0
- package/dist/tools/cpu/read-value.js.map +1 -0
- package/dist/tools/cpu/sample-trilinear.d.ts +43 -0
- package/dist/tools/cpu/sample-trilinear.js +168 -0
- package/dist/tools/cpu/sample-trilinear.js.map +1 -0
- package/dist/tools/cpu/stride-tables.d.ts +56 -0
- package/dist/tools/cpu/stride-tables.generated.d.ts +1059 -0
- package/dist/tools/cpu/stride-tables.generated.js +1267 -0
- package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
- package/dist/tools/cpu/stride-tables.js +78 -0
- package/dist/tools/cpu/stride-tables.js.map +1 -0
- package/dist/tools/cpu/surface-nets.d.ts +90 -0
- package/dist/tools/cpu/surface-nets.js +597 -0
- package/dist/tools/cpu/surface-nets.js.map +1 -0
- package/dist/tools/errors.d.ts +66 -0
- package/dist/tools/errors.js +67 -0
- package/dist/tools/errors.js.map +1 -0
- package/dist/tools/frame/ambient.d.ts +98 -0
- package/dist/tools/frame/ambient.js +274 -0
- package/dist/tools/frame/ambient.js.map +1 -0
- package/dist/tools/frame/blackbody.d.ts +57 -0
- package/dist/tools/frame/blackbody.js +151 -0
- package/dist/tools/frame/blackbody.js.map +1 -0
- package/dist/tools/frame/brick-cache.d.ts +165 -0
- package/dist/tools/frame/brick-cache.js +326 -0
- package/dist/tools/frame/brick-cache.js.map +1 -0
- package/dist/tools/frame/emission.d.ts +137 -0
- package/dist/tools/frame/emission.js +290 -0
- package/dist/tools/frame/emission.js.map +1 -0
- package/dist/tools/frame/environment-gpu.d.ts +111 -0
- package/dist/tools/frame/environment-gpu.js +280 -0
- package/dist/tools/frame/environment-gpu.js.map +1 -0
- package/dist/tools/frame/environment.d.ts +106 -0
- package/dist/tools/frame/environment.js +272 -0
- package/dist/tools/frame/environment.js.map +1 -0
- package/dist/tools/frame/froxel.d.ts +58 -0
- package/dist/tools/frame/froxel.js +115 -0
- package/dist/tools/frame/froxel.js.map +1 -0
- package/dist/tools/frame/grid.d.ts +392 -0
- package/dist/tools/frame/grid.js +802 -0
- package/dist/tools/frame/grid.js.map +1 -0
- package/dist/tools/frame/index.d.ts +150 -0
- package/dist/tools/frame/index.js +389 -0
- package/dist/tools/frame/index.js.map +1 -0
- package/dist/tools/frame/medium.d.ts +77 -0
- package/dist/tools/frame/medium.js +101 -0
- package/dist/tools/frame/medium.js.map +1 -0
- package/dist/tools/frame/mie-table.d.ts +6 -0
- package/dist/tools/frame/mie-table.js +16 -0
- package/dist/tools/frame/mie-table.js.map +1 -0
- package/dist/tools/frame/mie.d.ts +63 -0
- package/dist/tools/frame/mie.js +194 -0
- package/dist/tools/frame/mie.js.map +1 -0
- package/dist/tools/frame/mlp-nn.d.ts +36 -0
- package/dist/tools/frame/mlp-nn.js +159 -0
- package/dist/tools/frame/mlp-nn.js.map +1 -0
- package/dist/tools/frame/mlp-tza.d.ts +29 -0
- package/dist/tools/frame/mlp-tza.js +186 -0
- package/dist/tools/frame/mlp-tza.js.map +1 -0
- package/dist/tools/frame/mlp.d.ts +183 -0
- package/dist/tools/frame/mlp.js +434 -0
- package/dist/tools/frame/mlp.js.map +1 -0
- package/dist/tools/frame/ms-exit.d.ts +42 -0
- package/dist/tools/frame/ms-exit.js +90 -0
- package/dist/tools/frame/ms-exit.js.map +1 -0
- package/dist/tools/frame/multi-scale.d.ts +152 -0
- package/dist/tools/frame/multi-scale.js +302 -0
- package/dist/tools/frame/multi-scale.js.map +1 -0
- package/dist/tools/frame/neural-weights.d.ts +10 -0
- package/dist/tools/frame/neural-weights.js +244 -0
- package/dist/tools/frame/neural-weights.js.map +1 -0
- package/dist/tools/frame/neural.d.ts +80 -0
- package/dist/tools/frame/neural.js +150 -0
- package/dist/tools/frame/neural.js.map +1 -0
- package/dist/tools/frame/occluders.d.ts +51 -0
- package/dist/tools/frame/occluders.js +72 -0
- package/dist/tools/frame/occluders.js.map +1 -0
- package/dist/tools/frame/pyramid-layout.d.ts +55 -0
- package/dist/tools/frame/pyramid-layout.js +100 -0
- package/dist/tools/frame/pyramid-layout.js.map +1 -0
- package/dist/tools/frame/shadows.d.ts +190 -0
- package/dist/tools/frame/shadows.js +468 -0
- package/dist/tools/frame/shadows.js.map +1 -0
- package/dist/tools/frame/sparse.d.ts +147 -0
- package/dist/tools/frame/sparse.js +432 -0
- package/dist/tools/frame/sparse.js.map +1 -0
- package/dist/tools/frame/spectral-stack.d.ts +159 -0
- package/dist/tools/frame/spectral-stack.js +391 -0
- package/dist/tools/frame/spectral-stack.js.map +1 -0
- package/dist/tools/frame/spectral.d.ts +222 -0
- package/dist/tools/frame/spectral.js +572 -0
- package/dist/tools/frame/spectral.js.map +1 -0
- package/dist/tools/frame/stack.d.ts +115 -0
- package/dist/tools/frame/stack.js +290 -0
- package/dist/tools/frame/stack.js.map +1 -0
- package/dist/tools/frame/view.d.ts +131 -0
- package/dist/tools/frame/view.js +337 -0
- package/dist/tools/frame/view.js.map +1 -0
- package/dist/tools/index.d.ts +157 -0
- package/dist/tools/index.js +132 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/internal.d.ts +87 -0
- package/dist/tools/internal.js +85 -0
- package/dist/tools/internal.js.map +1 -0
- package/dist/tools/nanovdb/build-from-vdb.d.ts +59 -0
- package/dist/tools/nanovdb/build-from-vdb.js +100 -0
- package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
- package/dist/tools/nanovdb/bytes.d.ts +233 -0
- package/dist/tools/nanovdb/bytes.js +388 -0
- package/dist/tools/nanovdb/bytes.js.map +1 -0
- package/dist/tools/nanovdb/coarse-first.d.ts +78 -0
- package/dist/tools/nanovdb/coarse-first.js +92 -0
- package/dist/tools/nanovdb/coarse-first.js.map +1 -0
- package/dist/tools/nanovdb/half.d.ts +22 -0
- package/dist/tools/nanovdb/half.js +73 -0
- package/dist/tools/nanovdb/half.js.map +1 -0
- package/dist/tools/nanovdb/index.d.ts +34 -0
- package/dist/tools/nanovdb/index.js +25 -0
- package/dist/tools/nanovdb/index.js.map +1 -0
- package/dist/tools/nanovdb/inspect.d.ts +33 -0
- package/dist/tools/nanovdb/inspect.js +70 -0
- package/dist/tools/nanovdb/inspect.js.map +1 -0
- package/dist/tools/nanovdb/leaf-codec.d.ts +119 -0
- package/dist/tools/nanovdb/leaf-codec.js +356 -0
- package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
- package/dist/tools/nanovdb/quantize.d.ts +72 -0
- package/dist/tools/nanovdb/quantize.js +329 -0
- package/dist/tools/nanovdb/quantize.js.map +1 -0
- package/dist/tools/nanovdb/resample.d.ts +177 -0
- package/dist/tools/nanovdb/resample.js +692 -0
- package/dist/tools/nanovdb/resample.js.map +1 -0
- package/dist/tools/nanovdb/serialize.d.ts +176 -0
- package/dist/tools/nanovdb/serialize.js +439 -0
- package/dist/tools/nanovdb/serialize.js.map +1 -0
- package/dist/tools/nanovdb/stats.d.ts +87 -0
- package/dist/tools/nanovdb/stats.js +225 -0
- package/dist/tools/nanovdb/stats.js.map +1 -0
- package/dist/tools/nanovdb/transform.d.ts +30 -0
- package/dist/tools/nanovdb/transform.js +94 -0
- package/dist/tools/nanovdb/transform.js.map +1 -0
- package/dist/tools/nanovdb/tree.d.ts +186 -0
- package/dist/tools/nanovdb/tree.js +530 -0
- package/dist/tools/nanovdb/tree.js.map +1 -0
- package/dist/tools/nanovdb/write-nvdb.d.ts +74 -0
- package/dist/tools/nanovdb/write-nvdb.js +290 -0
- package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
- package/dist/tools/nvdb-file.d.ts +265 -0
- package/dist/tools/nvdb-file.js +763 -0
- package/dist/tools/nvdb-file.js.map +1 -0
- package/dist/tools/nvdb-stream.d.ts +154 -0
- package/dist/tools/nvdb-stream.js +409 -0
- package/dist/tools/nvdb-stream.js.map +1 -0
- package/dist/tools/reference/analytic.d.ts +41 -0
- package/dist/tools/reference/analytic.js +95 -0
- package/dist/tools/reference/analytic.js.map +1 -0
- package/dist/tools/reference/environment.d.ts +62 -0
- package/dist/tools/reference/environment.js +154 -0
- package/dist/tools/reference/environment.js.map +1 -0
- package/dist/tools/reference/index.d.ts +12 -0
- package/dist/tools/reference/index.js +13 -0
- package/dist/tools/reference/index.js.map +1 -0
- package/dist/tools/reference/media.d.ts +14 -0
- package/dist/tools/reference/media.js +30 -0
- package/dist/tools/reference/media.js.map +1 -0
- package/dist/tools/reference/rng.d.ts +20 -0
- package/dist/tools/reference/rng.js +30 -0
- package/dist/tools/reference/rng.js.map +1 -0
- package/dist/tools/reference/scene.d.ts +312 -0
- package/dist/tools/reference/scene.js +169 -0
- package/dist/tools/reference/scene.js.map +1 -0
- package/dist/tools/reference/tables.d.ts +98 -0
- package/dist/tools/reference/tables.js +264 -0
- package/dist/tools/reference/tables.js.map +1 -0
- package/dist/tools/reference/trace.d.ts +160 -0
- package/dist/tools/reference/trace.js +497 -0
- package/dist/tools/reference/trace.js.map +1 -0
- package/dist/tools/vdb/bit-utils.d.ts +20 -0
- package/dist/tools/vdb/bit-utils.js +42 -0
- package/dist/tools/vdb/bit-utils.js.map +1 -0
- package/dist/tools/vdb/blosc-write.d.ts +43 -0
- package/dist/tools/vdb/blosc-write.js +197 -0
- package/dist/tools/vdb/blosc-write.js.map +1 -0
- package/dist/tools/vdb/blosc.d.ts +86 -0
- package/dist/tools/vdb/blosc.js +287 -0
- package/dist/tools/vdb/blosc.js.map +1 -0
- package/dist/tools/vdb/blosclz.d.ts +33 -0
- package/dist/tools/vdb/blosclz.js +112 -0
- package/dist/tools/vdb/blosclz.js.map +1 -0
- package/dist/tools/vdb/byte-reader.d.ts +50 -0
- package/dist/tools/vdb/byte-reader.js +161 -0
- package/dist/tools/vdb/byte-reader.js.map +1 -0
- package/dist/tools/vdb/compression.d.ts +81 -0
- package/dist/tools/vdb/compression.js +260 -0
- package/dist/tools/vdb/compression.js.map +1 -0
- package/dist/tools/vdb/errors.d.ts +10 -0
- package/dist/tools/vdb/errors.js +11 -0
- package/dist/tools/vdb/errors.js.map +1 -0
- package/dist/tools/vdb/grid.d.ts +37 -0
- package/dist/tools/vdb/grid.js +153 -0
- package/dist/tools/vdb/grid.js.map +1 -0
- package/dist/tools/vdb/half-float.d.ts +9 -0
- package/dist/tools/vdb/half-float.js +24 -0
- package/dist/tools/vdb/half-float.js.map +1 -0
- package/dist/tools/vdb/index.d.ts +4 -0
- package/dist/tools/vdb/index.js +3 -0
- package/dist/tools/vdb/index.js.map +1 -0
- package/dist/tools/vdb/inflate.d.ts +24 -0
- package/dist/tools/vdb/inflate.js +334 -0
- package/dist/tools/vdb/inflate.js.map +1 -0
- package/dist/tools/vdb/lz4.d.ts +30 -0
- package/dist/tools/vdb/lz4.js +228 -0
- package/dist/tools/vdb/lz4.js.map +1 -0
- package/dist/tools/vdb/metadata.d.ts +17 -0
- package/dist/tools/vdb/metadata.js +72 -0
- package/dist/tools/vdb/metadata.js.map +1 -0
- package/dist/tools/vdb/parse.d.ts +47 -0
- package/dist/tools/vdb/parse.js +241 -0
- package/dist/tools/vdb/parse.js.map +1 -0
- package/dist/tools/vdb/point-render-data.d.ts +79 -0
- package/dist/tools/vdb/point-render-data.js +137 -0
- package/dist/tools/vdb/point-render-data.js.map +1 -0
- package/dist/tools/vdb/points.d.ts +186 -0
- package/dist/tools/vdb/points.js +835 -0
- package/dist/tools/vdb/points.js.map +1 -0
- package/dist/tools/vdb/transform.d.ts +23 -0
- package/dist/tools/vdb/transform.js +54 -0
- package/dist/tools/vdb/transform.js.map +1 -0
- package/dist/tools/vdb/tree.d.ts +111 -0
- package/dist/tools/vdb/tree.js +228 -0
- package/dist/tools/vdb/tree.js.map +1 -0
- package/dist/tools/vdb/types.d.ts +195 -0
- package/dist/tools/vdb/types.js +3 -0
- package/dist/tools/vdb/types.js.map +1 -0
- package/dist/tools/wvdb/bake.d.ts +145 -0
- package/dist/tools/wvdb/bake.js +361 -0
- package/dist/tools/wvdb/bake.js.map +1 -0
- package/dist/tools/wvdb/dense.d.ts +191 -0
- package/dist/tools/wvdb/dense.js +368 -0
- package/dist/tools/wvdb/dense.js.map +1 -0
- package/dist/tools/wvdb/format.d.ts +220 -0
- package/dist/tools/wvdb/format.js +306 -0
- package/dist/tools/wvdb/format.js.map +1 -0
- package/dist/tools/wvdb/index.d.ts +14 -0
- package/dist/tools/wvdb/index.js +15 -0
- package/dist/tools/wvdb/index.js.map +1 -0
- package/dist/tools/wvdb/level-set.d.ts +56 -0
- package/dist/tools/wvdb/level-set.js +153 -0
- package/dist/tools/wvdb/level-set.js.map +1 -0
- package/dist/tools/wvdb/nanovdb.d.ts +59 -0
- package/dist/tools/wvdb/nanovdb.js +64 -0
- package/dist/tools/wvdb/nanovdb.js.map +1 -0
- package/dist/tools/wvdb/partial.d.ts +74 -0
- package/dist/tools/wvdb/partial.js +233 -0
- package/dist/tools/wvdb/partial.js.map +1 -0
- package/dist/tools/wvdb/read.d.ts +336 -0
- package/dist/tools/wvdb/read.js +766 -0
- package/dist/tools/wvdb/read.js.map +1 -0
- package/dist/tools/wvdb/sha256.d.ts +7 -0
- package/dist/tools/wvdb/sha256.js +76 -0
- package/dist/tools/wvdb/sha256.js.map +1 -0
- package/dist/tools/wvdb/write.d.ts +149 -0
- package/dist/tools/wvdb/write.js +403 -0
- package/dist/tools/wvdb/write.js.map +1 -0
- package/package.json +83 -4
- package/vendor/LICENSE +201 -0
- package/vendor/NOTICE +19 -0
- package/vendor/VENDOR.md +100 -0
- package/vendor/pnanovdb.wgsl +1577 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/wvdb/wvdbKernel.js upsample L122–188, clearMissingBricks L193–211, chunk L230–344 (a
|
|
3
|
+
// multi-page LOD starts from the previous LOD upsampled to its size, then each page overwrites its bricks).
|
|
4
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
5
|
+
// Changes: per pending brick instead of the whole level; integer weights (8 fractional bits, round half up once at
|
|
6
|
+
// the end) so the core's GPU kernel and this twin agree byte for byte; recomputed from the event's levels on every
|
|
7
|
+
// page (no state). Divergences: DIVERGES.md (K4.22 row).
|
|
8
|
+
/**
|
|
9
|
+
* K4.22: show a `.wvdb` LOD while its pages stream in (spec §12.2). `WvdbStreamReader({ partialLods: true })` emits
|
|
10
|
+
* the LOD's levels after every page; {@link wvdbDensePartialVolume} turns such an event into the dense volume the
|
|
11
|
+
* frame renderer's dense source uploads. With `fill: 'upsample'` (default) the bricks that are stored but not
|
|
12
|
+
* decoded yet are filled from the coarser LOD, as his worker kernel does, so the picture only gains detail; with
|
|
13
|
+
* `fill: 'background'` they stay empty until their page lands.
|
|
14
|
+
*
|
|
15
|
+
* The fill itself runs on the GPU in the core's dense source (`vdbDenseSource`: a compute kernel fills the pending
|
|
16
|
+
* bricks and rebuilds the mip atlas); {@link wvdbDenseResolve} is its CPU twin, byte for byte, and the fallback for
|
|
17
|
+
* hosts without the core.
|
|
18
|
+
*/
|
|
19
|
+
import { VDBToolsError } from "../errors.js";
|
|
20
|
+
import { WVDB_BRICK_DIM, brickCounts, isMaskBitSet } from "./format.js";
|
|
21
|
+
import { wvdbDenseAssemble, wvdbDenseFillTexture, wvdbDenseVolume, wvdbMipAtlas, wvdbTexels, } from "./dense.js";
|
|
22
|
+
/** Weights are integers in [0, 256]: 8 fractional bits, as a GPU's trilinear filter. */
|
|
23
|
+
export const WVDB_UPSAMPLE_WEIGHT_ONE = 256;
|
|
24
|
+
/**
|
|
25
|
+
* One axis of the upsample from `sourceSize` texels to `size` (his `axis`, wvdbKernel.js L125–135): target texel `i`
|
|
26
|
+
* reads source position `clamp((i + ½)·sourceSize/size − ½, 0, sourceSize − 1)`; `lower`/`upper` are the two taps
|
|
27
|
+
* and `weight` the upper tap's weight in 1/256 (the exact fraction rounded half up), in integers.
|
|
28
|
+
*/
|
|
29
|
+
export function wvdbUpsampleAxis(size, sourceSize) {
|
|
30
|
+
const lower = new Uint32Array(size);
|
|
31
|
+
const upper = new Uint32Array(size);
|
|
32
|
+
const weight = new Uint32Array(size);
|
|
33
|
+
const den = 2 * size;
|
|
34
|
+
for (let i = 0; i < size; i++) {
|
|
35
|
+
// position · den = (2i + 1)·sourceSize − size, clamped to [0, (sourceSize − 1)·den]
|
|
36
|
+
const num = Math.min(Math.max((2 * i + 1) * sourceSize - size, 0), (sourceSize - 1) * den);
|
|
37
|
+
const lo = Math.floor(num / den);
|
|
38
|
+
const r = num - lo * den;
|
|
39
|
+
lower[i] = lo;
|
|
40
|
+
upper[i] = Math.min(lo + 1, sourceSize - 1);
|
|
41
|
+
weight[i] = Math.floor((r * WVDB_UPSAMPLE_WEIGHT_ONE + size) / den);
|
|
42
|
+
}
|
|
43
|
+
return { lower, upper, weight };
|
|
44
|
+
}
|
|
45
|
+
/** The bricks of `level` that are stored and not decoded yet (one bit per brick), and their count. */
|
|
46
|
+
export function wvdbPendingBricks(level) {
|
|
47
|
+
const words = Math.ceil(level.brickTotal / 32);
|
|
48
|
+
const pending = new Uint32Array(words);
|
|
49
|
+
let count = 0;
|
|
50
|
+
// A sparse LOD whose mask has not arrived: nothing is known to be stored.
|
|
51
|
+
if (level.layout === "sparse" && !level.mask)
|
|
52
|
+
return { pending, count };
|
|
53
|
+
for (let w = 0; w < words; w++) {
|
|
54
|
+
const valid = w === words - 1 && level.brickTotal % 32 !== 0 ? (1 << level.brickTotal % 32) - 1 : 0xffffffff;
|
|
55
|
+
const stored = level.layout === "sparse" ? level.mask[w] : valid;
|
|
56
|
+
const bits = (stored & ~level.decoded[w] & valid) >>> 0;
|
|
57
|
+
pending[w] = bits;
|
|
58
|
+
let b = bits;
|
|
59
|
+
while (b) {
|
|
60
|
+
b &= b - 1;
|
|
61
|
+
count++;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return { pending, count };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* CPU twin of the core's fill kernel (`vdbDenseFillCs`): `tex.data` with every pending brick replaced by the
|
|
68
|
+
* coarser texels upsampled to its size, per component, in integers: `c = Σ v · wx · wy · wz` over the 8 taps
|
|
69
|
+
* (weights in 1/256), then `(c + 2²³) >> 24`. Without a fill, a copy of `tex.data`.
|
|
70
|
+
*/
|
|
71
|
+
export function wvdbUpsampleTexels(tex) {
|
|
72
|
+
const out = new Uint8Array(tex.data);
|
|
73
|
+
const fill = tex.fill;
|
|
74
|
+
if (!fill || fill.count === 0)
|
|
75
|
+
return out;
|
|
76
|
+
const [w, h, d] = tex.dimensions;
|
|
77
|
+
const [sw, sh, sd] = fill.from.dimensions;
|
|
78
|
+
const tb = tex.texelBytes;
|
|
79
|
+
const src = fill.from.data;
|
|
80
|
+
if (src.length !== sw * sh * sd * tb)
|
|
81
|
+
throw new VDBToolsError("VDB_BAD_OPTION", `wvdbUpsampleTexels: the coarse texels are ${src.length} bytes, expected ${sw}x${sh}x${sd}x${tb}`);
|
|
82
|
+
const ax = wvdbUpsampleAxis(w, sw);
|
|
83
|
+
const ay = wvdbUpsampleAxis(h, sh);
|
|
84
|
+
const az = wvdbUpsampleAxis(d, sd);
|
|
85
|
+
const [cx, cy, cz] = brickCounts(tex.dimensions);
|
|
86
|
+
const ONE = WVDB_UPSAMPLE_WEIGHT_ONE;
|
|
87
|
+
for (let bz = 0; bz < cz; bz++) {
|
|
88
|
+
for (let by = 0; by < cy; by++) {
|
|
89
|
+
for (let bx = 0; bx < cx; bx++) {
|
|
90
|
+
if (!isMaskBitSet(fill.pending, bx + cx * (by + cy * bz)))
|
|
91
|
+
continue;
|
|
92
|
+
for (let z = bz * WVDB_BRICK_DIM; z < Math.min(d, (bz + 1) * WVDB_BRICK_DIM); z++) {
|
|
93
|
+
const z0 = az.lower[z] * sh;
|
|
94
|
+
const z1 = az.upper[z] * sh;
|
|
95
|
+
const wz = az.weight[z];
|
|
96
|
+
for (let y = by * WVDB_BRICK_DIM; y < Math.min(h, (by + 1) * WVDB_BRICK_DIM); y++) {
|
|
97
|
+
const y0 = (ay.lower[y] + z0) * sw;
|
|
98
|
+
const y1 = (ay.upper[y] + z0) * sw;
|
|
99
|
+
const y2 = (ay.lower[y] + z1) * sw;
|
|
100
|
+
const y3 = (ay.upper[y] + z1) * sw;
|
|
101
|
+
const wy = ay.weight[y];
|
|
102
|
+
for (let x = bx * WVDB_BRICK_DIM; x < Math.min(w, (bx + 1) * WVDB_BRICK_DIM); x++) {
|
|
103
|
+
const x0 = ax.lower[x];
|
|
104
|
+
const x1 = ax.upper[x];
|
|
105
|
+
const wx = ax.weight[x];
|
|
106
|
+
const o = (x + (y + z * h) * w) * tb;
|
|
107
|
+
for (let c = 0; c < tb; c++) {
|
|
108
|
+
const at = (i) => src[i * tb + c];
|
|
109
|
+
const c00 = at(x0 + y0) * (ONE - wx) + at(x1 + y0) * wx;
|
|
110
|
+
const c10 = at(x0 + y1) * (ONE - wx) + at(x1 + y1) * wx;
|
|
111
|
+
const c01 = at(x0 + y2) * (ONE - wx) + at(x1 + y2) * wx;
|
|
112
|
+
const c11 = at(x0 + y3) * (ONE - wx) + at(x1 + y3) * wx;
|
|
113
|
+
const c0 = c00 * (ONE - wy) + c10 * wy;
|
|
114
|
+
const c1 = c01 * (ONE - wy) + c11 * wy;
|
|
115
|
+
out[o + c] = Math.floor((c0 * (ONE - wz) + c1 * wz + 0x800000) / 0x1000000);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
/** True when a fill's mip level 1 comes from its coarser LOD: `mips: 'coarse'` and the coarse size is level 1's. */
|
|
126
|
+
export function wvdbFillCoarseMips(tex) {
|
|
127
|
+
const f = tex.fill;
|
|
128
|
+
return !!f && (f.mips ?? "coarse") === "coarse" && f.from.dimensions.every((v, a) => v === Math.max(1, Math.ceil(tex.dimensions[a] / 2)));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* CPU twin of a texture's GPU fill: the filled texels and (with a mip atlas) the atlas built from them, level 1 of
|
|
132
|
+
* the pending bricks from the coarser LOD with `mips: 'coarse'` (`vdbDenseMipCs`); no `fill`.
|
|
133
|
+
*/
|
|
134
|
+
export function wvdbDenseResolveTexture(tex) {
|
|
135
|
+
const fill = tex.fill;
|
|
136
|
+
if (!fill)
|
|
137
|
+
return tex;
|
|
138
|
+
const data = wvdbUpsampleTexels(tex);
|
|
139
|
+
const tb = tex.texelBytes;
|
|
140
|
+
const [cx, cy] = brickCounts(tex.dimensions);
|
|
141
|
+
// Level-1 texel (x, y, z) box-filters level-0 texels 2x..2x+1 (clamped): one brick holds them all (bricks are 8 wide).
|
|
142
|
+
const coarse = fill.count > 0 && wvdbFillCoarseMips(tex)
|
|
143
|
+
? (l) => {
|
|
144
|
+
for (let z = 0; z < l.depth; z++)
|
|
145
|
+
for (let y = 0; y < l.height; y++)
|
|
146
|
+
for (let x = 0; x < l.width; x++) {
|
|
147
|
+
const b = ((2 * x) >> 3) + cx * (((2 * y) >> 3) + cy * ((2 * z) >> 3));
|
|
148
|
+
if (!isMaskBitSet(fill.pending, b))
|
|
149
|
+
continue;
|
|
150
|
+
const i = (x + l.width * (y + l.height * z)) * tb;
|
|
151
|
+
for (let c = 0; c < tb; c++)
|
|
152
|
+
l.data[i + c] = fill.from.data[i + c];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
: undefined;
|
|
156
|
+
return { data, dimensions: tex.dimensions, format: tex.format, texelBytes: tb, mip: tex.mip ? wvdbMipAtlas(data, tex.dimensions, tb, coarse) : null };
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The CPU twin of the core dense source's fill (K4.22): `volume` with every texture's pending bricks upsampled
|
|
160
|
+
* from its coarser LOD and its mip atlas rebuilt from the result, as plain textures (no `fill`). Byte for byte
|
|
161
|
+
* what `vdbDenseSource` uploads for `volume` on the GPU. A host without the core uploads this instead. The
|
|
162
|
+
* stats are `volume`'s (baked, or from the texels with the pending bricks at background).
|
|
163
|
+
*/
|
|
164
|
+
export function wvdbDenseResolve(volume) {
|
|
165
|
+
const r = (t) => (t ? wvdbDenseResolveTexture(t) : null);
|
|
166
|
+
return { ...volume, density: r(volume.density), mask: r(volume.mask), albedo: r(volume.albedo), emission: r(volume.emission) };
|
|
167
|
+
}
|
|
168
|
+
/** Coarse texels per level and scale, so every page of a LOD shares one array (the core uploads it once). */
|
|
169
|
+
const coarseTexels = new WeakMap();
|
|
170
|
+
function coarseOf(grid, level, scale) {
|
|
171
|
+
let byScale = coarseTexels.get(level);
|
|
172
|
+
if (!byScale)
|
|
173
|
+
coarseTexels.set(level, (byScale = new Map()));
|
|
174
|
+
let data = byScale.get(scale);
|
|
175
|
+
if (!data)
|
|
176
|
+
byScale.set(scale, (data = wvdbTexels(grid, level, scale)));
|
|
177
|
+
return data;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The dense volume of a `.wvdb` stream event (`WvdbStreamReader({ partialLods: true })`): for a complete LOD,
|
|
181
|
+
* `wvdbDenseVolume(file, { lod })`; for a partial one, the LOD's levels as decoded so far, with (by default) a
|
|
182
|
+
* `fill` on each texture: its stored, undecoded bricks and the finest complete coarser LOD's texels to upsample
|
|
183
|
+
* there. Pass the result to `vdbDenseSource.replace` / `vdbDenseTextures(…).replace` like any LOD; the core fills
|
|
184
|
+
* on the GPU. The texels are copied now: later pages do not change the returned volume.
|
|
185
|
+
*
|
|
186
|
+
* The density mean is the header's baked one when the file has it (scale 1); else it comes from the decoded
|
|
187
|
+
* texels (pending bricks at background), so `normalizeDensity` may move while a LOD streams in. `maxDensity`
|
|
188
|
+
* also bounds the coarse texels (an upsampled texel never exceeds them).
|
|
189
|
+
*
|
|
190
|
+
* const reader = new WvdbStreamReader({ partialLods: true });
|
|
191
|
+
* for (const e of reader.push(bytes)) source.replace(wvdbDensePartialVolume(reader.file!, e));
|
|
192
|
+
*
|
|
193
|
+
* @param file The reader's file (`reader.file`): its grids hold the complete coarser LODs.
|
|
194
|
+
* @param event A stream event (partial or complete).
|
|
195
|
+
* @param o Grids, scales, mipmaps (as `wvdbDenseVolume`) and the fill.
|
|
196
|
+
*/
|
|
197
|
+
export function wvdbDensePartialVolume(file, event, o = {}) {
|
|
198
|
+
if (!file || !Array.isArray(file.grids))
|
|
199
|
+
throw new VDBToolsError("VDB_BAD_OPTION", "wvdbDensePartialVolume: pass the stream reader's file (reader.file)");
|
|
200
|
+
if (!event || !Array.isArray(event.levels))
|
|
201
|
+
throw new VDBToolsError("VDB_BAD_OPTION", "wvdbDensePartialVolume: pass a WvdbStreamReader event");
|
|
202
|
+
const fill = o.fill ?? "upsample";
|
|
203
|
+
if (fill !== "upsample" && fill !== "background")
|
|
204
|
+
throw new VDBToolsError("VDB_BAD_OPTION", `wvdbDensePartialVolume: fill must be 'upsample' or 'background', got ${JSON.stringify(o.fill)}`);
|
|
205
|
+
const fillMips = o.fillMips ?? "coarse";
|
|
206
|
+
if (fillMips !== "coarse" && fillMips !== "box")
|
|
207
|
+
throw new VDBToolsError("VDB_BAD_OPTION", `wvdbDensePartialVolume: fillMips must be 'coarse' or 'box', got ${JSON.stringify(o.fillMips)}`);
|
|
208
|
+
const { fill: _fill, fillMips: _fillMips, ...dense } = o;
|
|
209
|
+
if (event.complete)
|
|
210
|
+
return wvdbDenseVolume(file, { ...dense, lod: event.lod });
|
|
211
|
+
const levelOf = (grid) => {
|
|
212
|
+
const level = event.levels[file.grids.indexOf(grid)];
|
|
213
|
+
if (!level || level.kind !== "volume" || level.lod !== event.lod) {
|
|
214
|
+
throw new VDBToolsError("VDB_BAD_OPTION", `wvdbDensePartialVolume: the event has no LOD ${event.lod} level of "${grid.name}" (is it this file's event?)`);
|
|
215
|
+
}
|
|
216
|
+
return level;
|
|
217
|
+
};
|
|
218
|
+
return wvdbDenseAssemble(file, dense, event.lod, {
|
|
219
|
+
level: levelOf,
|
|
220
|
+
texture(grid, level, data, texelBytes, mipmaps, scale) {
|
|
221
|
+
let f = null;
|
|
222
|
+
// The finest complete LOD below this one (the reader completes LODs coarse first).
|
|
223
|
+
const coarse = fill === "upsample" ? grid.levels[Math.min(event.lod, grid.levels.length) - 1] : undefined;
|
|
224
|
+
if (coarse) {
|
|
225
|
+
const { pending, count } = wvdbPendingBricks(level);
|
|
226
|
+
if (count > 0)
|
|
227
|
+
f = { pending, count, from: { data: coarseOf(grid, coarse, scale), dimensions: [...coarse.dimensions] }, mips: fillMips };
|
|
228
|
+
}
|
|
229
|
+
return wvdbDenseFillTexture(data, [...level.dimensions], texelBytes, mipmaps, f);
|
|
230
|
+
},
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=partial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"partial.js","sourceRoot":"","sources":["../../../src/tools/wvdb/partial.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,2GAA2G;AAC3G,8GAA8G;AAC9G,4GAA4G;AAC5G,mHAAmH;AACnH,mHAAmH;AACnH,yDAAyD;AAEzD;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAiB,MAAM,aAAa,CAAC;AAEvF,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,YAAY,EACZ,UAAU,GAKX,MAAM,YAAY,CAAC;AAoBpB,wFAAwF;AACxF,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAE5C;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,UAAkB;IAC/D,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,KAAK,G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,CAAC;YACD,OAAO,oBAAoB,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,UAAU,CAAa,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;QAC/F,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/wvdb/wvdbKernel.js upsample L122–188, clearMissingBricks L193–211, chunk L230–344 (a\n// multi-page LOD starts from the previous LOD upsampled to its size, then each page overwrites its bricks).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: per pending brick instead of the whole level; integer weights (8 fractional bits, round half up once at\n// the end) so the core's GPU kernel and this twin agree byte for byte; recomputed from the event's levels on every\n// page (no state). Divergences: DIVERGES.md (K4.22 row).\n\n/**\n * K4.22: show a `.wvdb` LOD while its pages stream in (spec §12.2). `WvdbStreamReader({ partialLods: true })` emits\n * the LOD's levels after every page; {@link wvdbDensePartialVolume} turns such an event into the dense volume the\n * frame renderer's dense source uploads. With `fill: 'upsample'` (default) the bricks that are stored but not\n * decoded yet are filled from the coarser LOD, as his worker kernel does, so the picture only gains detail; with\n * `fill: 'background'` they stay empty until their page lands.\n *\n * The fill itself runs on the GPU in the core's dense source (`vdbDenseSource`: a compute kernel fills the pending\n * bricks and rebuilds the mip atlas); {@link wvdbDenseResolve} is its CPU twin, byte for byte, and the fallback for\n * hosts without the core.\n */\n\nimport { VDBToolsError } from \"../errors.js\";\nimport { WVDB_BRICK_DIM, brickCounts, isMaskBitSet, type WvdbVec3 } from \"./format.js\";\nimport type { WvdbFile, WvdbLodEvent, WvdbVolumeGrid, WvdbVolumeLevel } from \"./read.js\";\nimport {\n wvdbDenseAssemble,\n wvdbDenseFillTexture,\n wvdbDenseVolume,\n wvdbMipAtlas,\n wvdbTexels,\n type WvdbDenseFill,\n type WvdbDenseOptions,\n type WvdbDenseTexture,\n type WvdbDenseVolume,\n} from \"./dense.js\";\n\n/** How {@link wvdbDensePartialVolume} shows the bricks of a partial LOD that have not arrived yet. */\nexport type WvdbDensePartialFill = \"upsample\" | \"background\";\n\n/** Options of {@link wvdbDensePartialVolume}: those of `wvdbDenseVolume` (but the LOD: the event's) and the fill. */\nexport interface WvdbDensePartialOptions extends Omit<WvdbDenseOptions, \"lod\"> {\n /**\n * Bricks stored but not decoded yet: `'upsample'` (default) fills them from the finest complete coarser LOD\n * (his kernel's trilinear upsample; a `fill` on each texture, done by the core's dense source on the GPU or by\n * {@link wvdbDenseResolve}); `'background'` leaves the background there until their page lands.\n */\n fill?: WvdbDensePartialFill;\n /**\n * The mip atlas of an upsampled partial LOD (`WvdbDenseFill.mips`): `'coarse'` (default) takes level 1 of the\n * pending bricks from the coarser LOD, `'box'` builds it from the upsampled texels as his renderer does.\n */\n fillMips?: \"coarse\" | \"box\";\n}\n\n/** Weights are integers in [0, 256]: 8 fractional bits, as a GPU's trilinear filter. */\nexport const WVDB_UPSAMPLE_WEIGHT_ONE = 256;\n\n/**\n * One axis of the upsample from `sourceSize` texels to `size` (his `axis`, wvdbKernel.js L125–135): target texel `i`\n * reads source position `clamp((i + ½)·sourceSize/size − ½, 0, sourceSize − 1)`; `lower`/`upper` are the two taps\n * and `weight` the upper tap's weight in 1/256 (the exact fraction rounded half up), in integers.\n */\nexport function wvdbUpsampleAxis(size: number, sourceSize: number): { lower: Uint32Array; upper: Uint32Array; weight: Uint32Array } {\n const lower = new Uint32Array(size);\n const upper = new Uint32Array(size);\n const weight = new Uint32Array(size);\n const den = 2 * size;\n for (let i = 0; i < size; i++) {\n // position · den = (2i + 1)·sourceSize − size, clamped to [0, (sourceSize − 1)·den]\n const num = Math.min(Math.max((2 * i + 1) * sourceSize - size, 0), (sourceSize - 1) * den);\n const lo = Math.floor(num / den);\n const r = num - lo * den;\n lower[i] = lo;\n upper[i] = Math.min(lo + 1, sourceSize - 1);\n weight[i] = Math.floor((r * WVDB_UPSAMPLE_WEIGHT_ONE + size) / den);\n }\n return { lower, upper, weight };\n}\n\n/** The bricks of `level` that are stored and not decoded yet (one bit per brick), and their count. */\nexport function wvdbPendingBricks(level: WvdbVolumeLevel): { pending: Uint32Array; count: number } {\n const words = Math.ceil(level.brickTotal / 32);\n const pending = new Uint32Array(words);\n let count = 0;\n // A sparse LOD whose mask has not arrived: nothing is known to be stored.\n if (level.layout === \"sparse\" && !level.mask) return { pending, count };\n for (let w = 0; w < words; w++) {\n const valid = w === words - 1 && level.brickTotal % 32 !== 0 ? (1 << level.brickTotal % 32) - 1 : 0xffffffff;\n const stored = level.layout === \"sparse\" ? level.mask![w]! : valid;\n const bits = (stored & ~level.decoded[w]! & valid) >>> 0;\n pending[w] = bits;\n let b = bits;\n while (b) {\n b &= b - 1;\n count++;\n }\n }\n return { pending, count };\n}\n\n/**\n * CPU twin of the core's fill kernel (`vdbDenseFillCs`): `tex.data` with every pending brick replaced by the\n * coarser texels upsampled to its size, per component, in integers: `c = Σ v · wx · wy · wz` over the 8 taps\n * (weights in 1/256), then `(c + 2²³) >> 24`. Without a fill, a copy of `tex.data`.\n */\nexport function wvdbUpsampleTexels(tex: WvdbDenseTexture): Uint8Array<ArrayBuffer> {\n const out = new Uint8Array(tex.data);\n const fill = tex.fill;\n if (!fill || fill.count === 0) return out;\n const [w, h, d] = tex.dimensions;\n const [sw, sh, sd] = fill.from.dimensions;\n const tb = tex.texelBytes;\n const src = fill.from.data;\n if (src.length !== sw * sh * sd * tb) throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbUpsampleTexels: the coarse texels are ${src.length} bytes, expected ${sw}x${sh}x${sd}x${tb}`);\n const ax = wvdbUpsampleAxis(w, sw);\n const ay = wvdbUpsampleAxis(h, sh);\n const az = wvdbUpsampleAxis(d, sd);\n const [cx, cy, cz] = brickCounts(tex.dimensions);\n const ONE = WVDB_UPSAMPLE_WEIGHT_ONE;\n for (let bz = 0; bz < cz; bz++) {\n for (let by = 0; by < cy; by++) {\n for (let bx = 0; bx < cx; bx++) {\n if (!isMaskBitSet(fill.pending, bx + cx * (by + cy * bz))) continue;\n for (let z = bz * WVDB_BRICK_DIM; z < Math.min(d, (bz + 1) * WVDB_BRICK_DIM); z++) {\n const z0 = az.lower[z]! * sh;\n const z1 = az.upper[z]! * sh;\n const wz = az.weight[z]!;\n for (let y = by * WVDB_BRICK_DIM; y < Math.min(h, (by + 1) * WVDB_BRICK_DIM); y++) {\n const y0 = (ay.lower[y]! + z0) * sw;\n const y1 = (ay.upper[y]! + z0) * sw;\n const y2 = (ay.lower[y]! + z1) * sw;\n const y3 = (ay.upper[y]! + z1) * sw;\n const wy = ay.weight[y]!;\n for (let x = bx * WVDB_BRICK_DIM; x < Math.min(w, (bx + 1) * WVDB_BRICK_DIM); x++) {\n const x0 = ax.lower[x]!;\n const x1 = ax.upper[x]!;\n const wx = ax.weight[x]!;\n const o = (x + (y + z * h) * w) * tb;\n for (let c = 0; c < tb; c++) {\n const at = (i: number) => src[i * tb + c]!;\n const c00 = at(x0 + y0) * (ONE - wx) + at(x1 + y0) * wx;\n const c10 = at(x0 + y1) * (ONE - wx) + at(x1 + y1) * wx;\n const c01 = at(x0 + y2) * (ONE - wx) + at(x1 + y2) * wx;\n const c11 = at(x0 + y3) * (ONE - wx) + at(x1 + y3) * wx;\n const c0 = c00 * (ONE - wy) + c10 * wy;\n const c1 = c01 * (ONE - wy) + c11 * wy;\n out[o + c] = Math.floor((c0 * (ONE - wz) + c1 * wz + 0x800000) / 0x1000000);\n }\n }\n }\n }\n }\n }\n }\n return out;\n}\n\n/** True when a fill's mip level 1 comes from its coarser LOD: `mips: 'coarse'` and the coarse size is level 1's. */\nexport function wvdbFillCoarseMips(tex: WvdbDenseTexture): boolean {\n const f = tex.fill;\n return !!f && (f.mips ?? \"coarse\") === \"coarse\" && f.from.dimensions.every((v, a) => v === Math.max(1, Math.ceil(tex.dimensions[a]! / 2)));\n}\n\n/**\n * CPU twin of a texture's GPU fill: the filled texels and (with a mip atlas) the atlas built from them, level 1 of\n * the pending bricks from the coarser LOD with `mips: 'coarse'` (`vdbDenseMipCs`); no `fill`.\n */\nexport function wvdbDenseResolveTexture(tex: WvdbDenseTexture): WvdbDenseTexture {\n const fill = tex.fill;\n if (!fill) return tex;\n const data = wvdbUpsampleTexels(tex);\n const tb = tex.texelBytes;\n const [cx, cy] = brickCounts(tex.dimensions);\n // Level-1 texel (x, y, z) box-filters level-0 texels 2x..2x+1 (clamped): one brick holds them all (bricks are 8 wide).\n const coarse = fill.count > 0 && wvdbFillCoarseMips(tex)\n ? (l: { data: Uint8Array; width: number; height: number; depth: number }) => {\n for (let z = 0; z < l.depth; z++)\n for (let y = 0; y < l.height; y++)\n for (let x = 0; x < l.width; x++) {\n const b = ((2 * x) >> 3) + cx * (((2 * y) >> 3) + cy * ((2 * z) >> 3));\n if (!isMaskBitSet(fill.pending, b)) continue;\n const i = (x + l.width * (y + l.height * z)) * tb;\n for (let c = 0; c < tb; c++) l.data[i + c] = fill.from.data[i + c]!;\n }\n }\n : undefined;\n return { data, dimensions: tex.dimensions, format: tex.format, texelBytes: tb, mip: tex.mip ? wvdbMipAtlas(data, tex.dimensions, tb, coarse) : null };\n}\n\n/**\n * The CPU twin of the core dense source's fill (K4.22): `volume` with every texture's pending bricks upsampled\n * from its coarser LOD and its mip atlas rebuilt from the result, as plain textures (no `fill`). Byte for byte\n * what `vdbDenseSource` uploads for `volume` on the GPU. A host without the core uploads this instead. The\n * stats are `volume`'s (baked, or from the texels with the pending bricks at background).\n */\nexport function wvdbDenseResolve(volume: WvdbDenseVolume): WvdbDenseVolume {\n const r = (t: WvdbDenseTexture | null) => (t ? wvdbDenseResolveTexture(t) : null);\n return { ...volume, density: r(volume.density)!, mask: r(volume.mask), albedo: r(volume.albedo), emission: r(volume.emission) };\n}\n\n/** Coarse texels per level and scale, so every page of a LOD shares one array (the core uploads it once). */\nconst coarseTexels = new WeakMap<WvdbVolumeLevel, Map<number, Uint8Array<ArrayBuffer>>>();\n\nfunction coarseOf(grid: WvdbVolumeGrid, level: WvdbVolumeLevel, scale: number): Uint8Array<ArrayBuffer> {\n let byScale = coarseTexels.get(level);\n if (!byScale) coarseTexels.set(level, (byScale = new Map()));\n let data = byScale.get(scale);\n if (!data) byScale.set(scale, (data = wvdbTexels(grid, level, scale)));\n return data;\n}\n\n/**\n * The dense volume of a `.wvdb` stream event (`WvdbStreamReader({ partialLods: true })`): for a complete LOD,\n * `wvdbDenseVolume(file, { lod })`; for a partial one, the LOD's levels as decoded so far, with (by default) a\n * `fill` on each texture: its stored, undecoded bricks and the finest complete coarser LOD's texels to upsample\n * there. Pass the result to `vdbDenseSource.replace` / `vdbDenseTextures(…).replace` like any LOD; the core fills\n * on the GPU. The texels are copied now: later pages do not change the returned volume.\n *\n * The density mean is the header's baked one when the file has it (scale 1); else it comes from the decoded\n * texels (pending bricks at background), so `normalizeDensity` may move while a LOD streams in. `maxDensity`\n * also bounds the coarse texels (an upsampled texel never exceeds them).\n *\n * const reader = new WvdbStreamReader({ partialLods: true });\n * for (const e of reader.push(bytes)) source.replace(wvdbDensePartialVolume(reader.file!, e));\n *\n * @param file The reader's file (`reader.file`): its grids hold the complete coarser LODs.\n * @param event A stream event (partial or complete).\n * @param o Grids, scales, mipmaps (as `wvdbDenseVolume`) and the fill.\n */\nexport function wvdbDensePartialVolume(file: WvdbFile, event: WvdbLodEvent, o: WvdbDensePartialOptions = {}): WvdbDenseVolume {\n if (!file || !Array.isArray(file.grids)) throw new VDBToolsError(\"VDB_BAD_OPTION\", \"wvdbDensePartialVolume: pass the stream reader's file (reader.file)\");\n if (!event || !Array.isArray(event.levels)) throw new VDBToolsError(\"VDB_BAD_OPTION\", \"wvdbDensePartialVolume: pass a WvdbStreamReader event\");\n const fill = o.fill ?? \"upsample\";\n if (fill !== \"upsample\" && fill !== \"background\") throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbDensePartialVolume: fill must be 'upsample' or 'background', got ${JSON.stringify(o.fill)}`);\n const fillMips = o.fillMips ?? \"coarse\";\n if (fillMips !== \"coarse\" && fillMips !== \"box\") throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbDensePartialVolume: fillMips must be 'coarse' or 'box', got ${JSON.stringify(o.fillMips)}`);\n const { fill: _fill, fillMips: _fillMips, ...dense } = o;\n if (event.complete) return wvdbDenseVolume(file, { ...dense, lod: event.lod });\n const levelOf = (grid: WvdbVolumeGrid): WvdbVolumeLevel => {\n const level = event.levels[file.grids.indexOf(grid)];\n if (!level || level.kind !== \"volume\" || level.lod !== event.lod) {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbDensePartialVolume: the event has no LOD ${event.lod} level of \"${grid.name}\" (is it this file's event?)`);\n }\n return level;\n };\n return wvdbDenseAssemble(file, dense, event.lod, {\n level: levelOf,\n texture(grid, level, data, texelBytes, mipmaps, scale) {\n let f: WvdbDenseFill | null = null;\n // The finest complete LOD below this one (the reader completes LODs coarse first).\n const coarse = fill === \"upsample\" ? grid.levels[Math.min(event.lod, grid.levels.length) - 1] : undefined;\n if (coarse) {\n const { pending, count } = wvdbPendingBricks(level);\n if (count > 0) f = { pending, count, from: { data: coarseOf(grid, coarse, scale), dimensions: [...coarse.dimensions] as WvdbVec3 }, mips: fillMips };\n }\n return wvdbDenseFillTexture(data, [...level.dimensions] as WvdbVec3, texelBytes, mipmaps, f);\n },\n });\n}\n"]}
|
|
@@ -0,0 +1,336 @@
|
|
|
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 { type WvdbBake, type WvdbBox, type WvdbGridClass, type WvdbGridHeader, type WvdbHeader, type WvdbLayout, type WvdbPointsGridHeader, type WvdbSource, type WvdbVec3, type WvdbVolumeGridHeader } from "./format.js";
|
|
21
|
+
/** A parsed preamble and header, with where the data section starts. */
|
|
22
|
+
export interface WvdbHeaderInfo {
|
|
23
|
+
/** The parsed JSON header. */
|
|
24
|
+
header: WvdbHeader;
|
|
25
|
+
/** File version from the preamble (equals `header.version`). */
|
|
26
|
+
version: number;
|
|
27
|
+
/** Absolute file offset of the data section; chunk offsets are relative to it. */
|
|
28
|
+
dataStart: number;
|
|
29
|
+
}
|
|
30
|
+
/** Options of {@link readWvdbHeader}: the §14 limits and checks. */
|
|
31
|
+
export interface ReadWvdbHeaderOptions {
|
|
32
|
+
/**
|
|
33
|
+
* Total file length, when known. Enables the §14 checks that need it:
|
|
34
|
+
* `headerLength <= fileLength - 12` and every chunk inside the data section.
|
|
35
|
+
*/
|
|
36
|
+
fileLength?: number;
|
|
37
|
+
/** Refuse a LOD whose `X * Y * Z * channels` exceeds this before allocating (§14). Default 2^28. */
|
|
38
|
+
maxVoxels?: number;
|
|
39
|
+
/** Also check the §9 chunk order: coarse to fine, grid order, no gaps. Default false. */
|
|
40
|
+
strictChunkOrder?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** §5.4: any other class string reads as `"unknown"`. */
|
|
43
|
+
export declare function normalizeWvdbClass(value: string): WvdbGridClass;
|
|
44
|
+
/**
|
|
45
|
+
* Reads the preamble and header. Returns `null` while `bytes` (a prefix of
|
|
46
|
+
* the file) does not yet hold the whole header; throws `WvdbFormatError` on a
|
|
47
|
+
* bad magic, an unsupported version, or a header that breaks §5/§14.
|
|
48
|
+
* @param bytes A prefix of the file (at least the preamble to get anything back).
|
|
49
|
+
* @param opts Limits and optional checks.
|
|
50
|
+
*/
|
|
51
|
+
export declare function readWvdbHeader(bytes: Uint8Array, opts?: ReadWvdbHeaderOptions): WvdbHeaderInfo | null;
|
|
52
|
+
/** One chunk of the data section, as {@link wvdbChunks} lists them. */
|
|
53
|
+
export interface WvdbChunkInfo {
|
|
54
|
+
/** Index into `header.grids`. */
|
|
55
|
+
gridIndex: number;
|
|
56
|
+
/** The LOD the chunk belongs to. */
|
|
57
|
+
lod: number;
|
|
58
|
+
/** What the chunk holds: a sparse LOD's mask, a page of bricks, or a page of points. */
|
|
59
|
+
kind: "mask" | "page" | "points";
|
|
60
|
+
/** Relative to dataStart. */
|
|
61
|
+
offset: number;
|
|
62
|
+
/** Compressed byte length. */
|
|
63
|
+
length: number;
|
|
64
|
+
/** page: bricks in the page; points: points in the chunk; mask: 0. */
|
|
65
|
+
count: number;
|
|
66
|
+
/** page: index of the first brick of a dense page. points: stored index of the first point. */
|
|
67
|
+
first: number;
|
|
68
|
+
}
|
|
69
|
+
/** All chunks in §9 writer order (LOD, then grid, then mask, then pages). */
|
|
70
|
+
export declare function wvdbChunks(header: WvdbHeader): WvdbChunkInfo[];
|
|
71
|
+
/**
|
|
72
|
+
* Absolute file byte range `[start, end)` that holds the chunks of `lod` for
|
|
73
|
+
* all grids (one contiguous range in a conforming file, §9). `start === end`
|
|
74
|
+
* when the LOD has no chunks.
|
|
75
|
+
* @param info The parsed header.
|
|
76
|
+
* @param lod LOD index (0 is the coarsest).
|
|
77
|
+
*/
|
|
78
|
+
export declare function wvdbLodByteRange(info: WvdbHeaderInfo, lod: number): {
|
|
79
|
+
start: number;
|
|
80
|
+
end: number;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Bytes from the start of the file needed to decode LODs 0..lod (header included).
|
|
84
|
+
* @param info The parsed header.
|
|
85
|
+
* @param lod The last LOD to decode.
|
|
86
|
+
*/
|
|
87
|
+
export declare function wvdbPrefixLength(info: WvdbHeaderInfo, lod: number): number;
|
|
88
|
+
/** One decoded LOD of a volume grid. */
|
|
89
|
+
export interface WvdbVolumeLevel {
|
|
90
|
+
/** Discriminant: a volume level. */
|
|
91
|
+
kind: "volume";
|
|
92
|
+
/** LOD index (0 is the coarsest). */
|
|
93
|
+
lod: number;
|
|
94
|
+
/** Voxels per axis. */
|
|
95
|
+
dimensions: WvdbVec3;
|
|
96
|
+
/** Brick layout the LOD was stored in. */
|
|
97
|
+
layout: WvdbLayout;
|
|
98
|
+
/** Channels per voxel. */
|
|
99
|
+
channels: 1 | 3;
|
|
100
|
+
/** Bricks per axis (`ceil(dimensions / 8)`). */
|
|
101
|
+
brickCounts: WvdbVec3;
|
|
102
|
+
/** Bricks in the whole LOD, stored or not. */
|
|
103
|
+
brickTotal: number;
|
|
104
|
+
/** Mask words of a sparse LOD (bit `index` set = stored); null for dense. */
|
|
105
|
+
mask: Uint32Array | null;
|
|
106
|
+
/** Stored brick indices in file order (dense: 0..brickTotal-1). */
|
|
107
|
+
brickIndices: Uint32Array;
|
|
108
|
+
/** Brick channel ranges in file order, `b * channels + c`. */
|
|
109
|
+
mins: Float32Array;
|
|
110
|
+
/** The matching maxima, same indexing as `mins`. */
|
|
111
|
+
maxs: Float32Array;
|
|
112
|
+
/** Dense decoded values: channel planes, x fastest; background where no brick is stored. */
|
|
113
|
+
values: Float32Array;
|
|
114
|
+
/** Bricks decoded so far (equals the LOD's brick count once complete; less in a partial stream event). */
|
|
115
|
+
bricksDecoded: number;
|
|
116
|
+
/**
|
|
117
|
+
* K4.22: one bit per brick (word `index >> 5`, bit `index & 31`), set once its page is decoded. Equals the
|
|
118
|
+
* stored bricks once complete; a partial stream event's undecoded stored bricks are the ones to fill.
|
|
119
|
+
*/
|
|
120
|
+
decoded: Uint32Array;
|
|
121
|
+
}
|
|
122
|
+
/** One decoded LOD of a points grid. */
|
|
123
|
+
export interface WvdbPointsLevel {
|
|
124
|
+
/** Discriminant: a points level. */
|
|
125
|
+
kind: "points";
|
|
126
|
+
/** LOD index (0 is the coarsest). */
|
|
127
|
+
lod: number;
|
|
128
|
+
/** Stored index of the first point of this LOD within the LOD-ordered point list. */
|
|
129
|
+
firstPoint: number;
|
|
130
|
+
/** Points this LOD adds. */
|
|
131
|
+
count: number;
|
|
132
|
+
/** xyz per point. */
|
|
133
|
+
positions: Float32Array;
|
|
134
|
+
/** rgb per point in [0, 1], or null when the grid has no colours. */
|
|
135
|
+
colors: Float32Array | null;
|
|
136
|
+
/** Points decoded so far (equals `count` once complete; less in a partial stream event). */
|
|
137
|
+
pointsDecoded: number;
|
|
138
|
+
}
|
|
139
|
+
/** A decoded LOD of either grid kind. */
|
|
140
|
+
export type WvdbLevel = WvdbVolumeLevel | WvdbPointsLevel;
|
|
141
|
+
interface WvdbGridBase {
|
|
142
|
+
name: string;
|
|
143
|
+
/** Normalized per §5.4 (unknown strings become `"unknown"`). */
|
|
144
|
+
class: WvdbGridClass;
|
|
145
|
+
bbox: WvdbBox | null;
|
|
146
|
+
header: WvdbGridHeader;
|
|
147
|
+
}
|
|
148
|
+
/** A decoded volume grid. */
|
|
149
|
+
export interface WvdbVolumeGrid extends WvdbGridBase {
|
|
150
|
+
/** Discriminant: a volume grid. */
|
|
151
|
+
kind: "volume";
|
|
152
|
+
/** Channels per voxel. */
|
|
153
|
+
channels: 1 | 3;
|
|
154
|
+
/** One value per channel. */
|
|
155
|
+
background: number[];
|
|
156
|
+
/** Baked mean density, when the header has it. */
|
|
157
|
+
meanDensity?: number;
|
|
158
|
+
/** Baked count of non-zero voxels, when the header has it. */
|
|
159
|
+
nonZeroVoxels?: number;
|
|
160
|
+
/** The grid's header record. */
|
|
161
|
+
header: WvdbVolumeGridHeader;
|
|
162
|
+
/** Decoded LODs, coarse first (`levels[k].lod === k`). */
|
|
163
|
+
levels: WvdbVolumeLevel[];
|
|
164
|
+
}
|
|
165
|
+
/** A decoded points grid. */
|
|
166
|
+
export interface WvdbPointsGrid extends WvdbGridBase {
|
|
167
|
+
/** Discriminant: a points grid. */
|
|
168
|
+
kind: "points";
|
|
169
|
+
/** Points in the grid, all LODs together. */
|
|
170
|
+
count: number;
|
|
171
|
+
/** Points in the source before thinning, when recorded. */
|
|
172
|
+
sourceCount?: number;
|
|
173
|
+
/** Mean point spacing in world units, when recorded. */
|
|
174
|
+
spacing?: number;
|
|
175
|
+
/** True when the points carry colours. */
|
|
176
|
+
colors: boolean;
|
|
177
|
+
/** The grid's header record. */
|
|
178
|
+
header: WvdbPointsGridHeader;
|
|
179
|
+
/** Decoded LODs, coarse first. LOD k adds its points to LODs 0..k-1 (§3.5). */
|
|
180
|
+
levels: WvdbPointsLevel[];
|
|
181
|
+
}
|
|
182
|
+
/** A decoded grid of either kind. */
|
|
183
|
+
export type WvdbGrid = WvdbVolumeGrid | WvdbPointsGrid;
|
|
184
|
+
/** A decoded `.wvdb` file: its header and the LODs read so far. */
|
|
185
|
+
export interface WvdbFile {
|
|
186
|
+
/** File version. */
|
|
187
|
+
version: number;
|
|
188
|
+
/** The parsed header. */
|
|
189
|
+
header: WvdbHeader;
|
|
190
|
+
/** Absolute file offset of the data section. */
|
|
191
|
+
dataStart: number;
|
|
192
|
+
/** `header.source`. */
|
|
193
|
+
source: WvdbSource;
|
|
194
|
+
/** `header.bake`. */
|
|
195
|
+
bake: WvdbBake;
|
|
196
|
+
/** The decoded grids, in header order. */
|
|
197
|
+
grids: WvdbGrid[];
|
|
198
|
+
/** Number of LODs decoded (LODs 0..lodsDecoded-1). */
|
|
199
|
+
lodsDecoded: number;
|
|
200
|
+
/** True when every LOD of the file is decoded. */
|
|
201
|
+
complete: boolean;
|
|
202
|
+
}
|
|
203
|
+
/** Inflates one zlib chunk, stopping past `maxSize` bytes (§14). */
|
|
204
|
+
export declare function inflateWvdbChunk(bytes: Uint8Array, maxSize: number): Uint8Array;
|
|
205
|
+
/**
|
|
206
|
+
* Decodes LOD `lod` of every grid. `bytes` holds file bytes starting at file
|
|
207
|
+
* offset `byteOffset` (0 for the whole file or a prefix; `range.start` for a
|
|
208
|
+
* range read from `wvdbLodByteRange`). Returns one level per grid, in header
|
|
209
|
+
* order.
|
|
210
|
+
* @param info The parsed header.
|
|
211
|
+
* @param lod The LOD to decode.
|
|
212
|
+
* @param bytes File bytes holding every chunk of that LOD.
|
|
213
|
+
* @param byteOffset File offset of `bytes[0]`.
|
|
214
|
+
*/
|
|
215
|
+
export declare function decodeWvdbLod(info: WvdbHeaderInfo, lod: number, bytes: Uint8Array, byteOffset?: number): WvdbLevel[];
|
|
216
|
+
/** Options of {@link readWvdb}: the header limits, a LOD cap and prefix reads. */
|
|
217
|
+
export interface ReadWvdbOptions extends Omit<ReadWvdbHeaderOptions, "fileLength"> {
|
|
218
|
+
/** Decode LODs 0..maxLod only. Default: all. */
|
|
219
|
+
maxLod?: number;
|
|
220
|
+
/**
|
|
221
|
+
* `bytes` is a prefix of the file (a stream so far, or a `Range: bytes=0-N`
|
|
222
|
+
* read): decode the LODs it holds completely and stop. Default false: the
|
|
223
|
+
* bytes are the whole file, and every chunk must be inside them.
|
|
224
|
+
*/
|
|
225
|
+
partial?: boolean;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Reads a `.wvdb` file (or, with `partial`, a prefix of one) and decodes its
|
|
229
|
+
* LODs coarse to fine.
|
|
230
|
+
* @param input The file's bytes (or a prefix with `partial`).
|
|
231
|
+
* @param opts LOD cap, prefix mode and header limits.
|
|
232
|
+
*/
|
|
233
|
+
export declare function readWvdb(input: Uint8Array | ArrayBuffer, opts?: ReadWvdbOptions): WvdbFile;
|
|
234
|
+
/** What {@link WvdbStreamReader.push} reports: a LOD that finished, or gained a chunk. */
|
|
235
|
+
export interface WvdbLodEvent {
|
|
236
|
+
/** The LOD index. */
|
|
237
|
+
lod: number;
|
|
238
|
+
/**
|
|
239
|
+
* One level per grid, in header order. For a partial event these are the
|
|
240
|
+
* LOD's levels in progress: later pages fill the same objects, and
|
|
241
|
+
* `bricksDecoded` / `pointsDecoded` say how much is in.
|
|
242
|
+
*/
|
|
243
|
+
levels: WvdbLevel[];
|
|
244
|
+
/** True once every chunk of the LOD is decoded (always, unless `partialLods`). */
|
|
245
|
+
complete: boolean;
|
|
246
|
+
/** Partial events: the chunk just decoded (a page's bricks are `brickIndices[first .. first + count)`). */
|
|
247
|
+
chunk?: WvdbChunkInfo;
|
|
248
|
+
}
|
|
249
|
+
/** Options of {@link WvdbStreamReader}. */
|
|
250
|
+
export interface WvdbStreamReaderOptions extends Omit<ReadWvdbOptions, "partial"> {
|
|
251
|
+
/**
|
|
252
|
+
* Also emit an event (`complete: false`) after every chunk of a LOD decodes,
|
|
253
|
+
* so a LOD can be shown before all its pages arrive (§12.2). Default false:
|
|
254
|
+
* one event per finished LOD.
|
|
255
|
+
*/
|
|
256
|
+
partialLods?: boolean;
|
|
257
|
+
/** Refuse a header longer than this many bytes before buffering it. Default 16 MiB. */
|
|
258
|
+
maxHeaderBytes?: number;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Largest compressed size accepted for a chunk that inflates to at most `n`
|
|
262
|
+
* bytes: zlib's `compressBound` is about `n + n/4096 + 13`; this allows
|
|
263
|
+
* `n + n/1024 + 1 KiB`, which any deflate encoder's output fits (stored blocks
|
|
264
|
+
* cost 5 bytes per 64 KiB). The stream reader holds one chunk's bytes at a
|
|
265
|
+
* time, so this is its memory bound.
|
|
266
|
+
*/
|
|
267
|
+
export declare function wvdbChunkByteLimit(inflatedBytes: number): number;
|
|
268
|
+
/**
|
|
269
|
+
* Push-style coarse-first decoder for a `.wvdb` download: feed it the bytes
|
|
270
|
+
* as they arrive; each `push` returns the LODs that became complete (and,
|
|
271
|
+
* with `partialLods`, the LODs that gained a page).
|
|
272
|
+
*
|
|
273
|
+
* const reader = new WvdbStreamReader({ partialLods: true });
|
|
274
|
+
* for await (const chunk of response.body) for (const e of reader.push(chunk)) show(e);
|
|
275
|
+
* reader.end();
|
|
276
|
+
*
|
|
277
|
+
* Chunks are decoded one at a time, in file order, as soon as their last byte
|
|
278
|
+
* arrives, so the reader holds at most one chunk's compressed bytes (plus the
|
|
279
|
+
* header until it parses) besides the decoded LODs: `peakBufferedBytes` is
|
|
280
|
+
* bounded by the largest chunk plus one pushed buffer. Each chunk's length is
|
|
281
|
+
* checked against {@link wvdbChunkByteLimit} when the header arrives. After an
|
|
282
|
+
* error, every later call throws the same error.
|
|
283
|
+
|
|
284
|
+
*/
|
|
285
|
+
export declare class WvdbStreamReader {
|
|
286
|
+
private readonly opts;
|
|
287
|
+
private buf;
|
|
288
|
+
/** Absolute file offset of `buf[0]`, and one past the last byte held. */
|
|
289
|
+
private bufStart;
|
|
290
|
+
private bufEnd;
|
|
291
|
+
private received;
|
|
292
|
+
private next;
|
|
293
|
+
private finalLod;
|
|
294
|
+
private chunks;
|
|
295
|
+
private ci;
|
|
296
|
+
private remaining;
|
|
297
|
+
private decoders;
|
|
298
|
+
private failure;
|
|
299
|
+
private peak;
|
|
300
|
+
/** The parsed header, or null before it has arrived. */
|
|
301
|
+
info: WvdbHeaderInfo | null;
|
|
302
|
+
/** The decoded file so far (grids gain levels as LODs complete); null before the header. */
|
|
303
|
+
file: WvdbFile | null;
|
|
304
|
+
/** @param opts LOD cap, partial-LOD events and header limits. */
|
|
305
|
+
constructor(opts?: WvdbStreamReaderOptions);
|
|
306
|
+
/** The parsed JSON header, or null before it has arrived. */
|
|
307
|
+
get header(): WvdbHeader | null;
|
|
308
|
+
/** True when every LOD up to `maxLod` is decoded. */
|
|
309
|
+
get done(): boolean;
|
|
310
|
+
/** File bytes needed to finish (header known), or null before the header. */
|
|
311
|
+
get bytesTotal(): number | null;
|
|
312
|
+
/** File bytes pushed so far. */
|
|
313
|
+
get bytesReceived(): number;
|
|
314
|
+
/** Compressed bytes held now, and the most ever held. */
|
|
315
|
+
get bufferedBytes(): number;
|
|
316
|
+
/** The most compressed bytes the reader has held at once. */
|
|
317
|
+
get peakBufferedBytes(): number;
|
|
318
|
+
/**
|
|
319
|
+
* Feeds the next bytes of the download and decodes what they complete.
|
|
320
|
+
* @param chunk The next bytes, in file order.
|
|
321
|
+
* @returns The LOD events this push produced (possibly none).
|
|
322
|
+
*/
|
|
323
|
+
push(chunk: Uint8Array): WvdbLodEvent[];
|
|
324
|
+
/** Call when the stream ends: throws `WvdbFormatError` if a LOD up to `maxLod` is still missing. */
|
|
325
|
+
end(): void;
|
|
326
|
+
/** Absolute offset below which no byte is needed any more. */
|
|
327
|
+
private keepFrom;
|
|
328
|
+
/** Drops held bytes before `keepFrom()`. */
|
|
329
|
+
private compact;
|
|
330
|
+
private append;
|
|
331
|
+
private readHeader;
|
|
332
|
+
private decodersFor;
|
|
333
|
+
private decodeChunks;
|
|
334
|
+
private completeLods;
|
|
335
|
+
}
|
|
336
|
+
export {};
|