@pmndrs/vdb 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +592 -2
- package/README.md +85 -37
- package/THIRD_PARTY_NOTICES.md +197 -29
- package/dist/core/compute/atlas.d.ts +10 -2
- package/dist/core/compute/atlas.js +6 -1
- package/dist/core/compute/atlas.js.map +1 -1
- package/dist/core/compute/index.d.ts +3 -3
- package/dist/core/compute/index.js +2 -2
- package/dist/core/compute/index.js.map +1 -1
- 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 +22 -7
- package/dist/core/compute/pyramid.js +22 -9
- package/dist/core/compute/pyramid.js.map +1 -1
- package/dist/core/compute/shared.d.ts +1 -0
- package/dist/core/compute/shared.js.map +1 -1
- package/dist/core/compute/stats.d.ts +10 -3
- package/dist/core/compute/stats.js +6 -1
- package/dist/core/compute/stats.js.map +1 -1
- package/dist/core/compute/value-transform.d.ts +8 -1
- package/dist/core/compute/value-transform.js +9 -3
- package/dist/core/compute/value-transform.js.map +1 -1
- package/dist/core/errors.d.ts +10 -0
- package/dist/core/errors.js +8 -0
- package/dist/core/errors.js.map +1 -1
- 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 +25 -3
- package/dist/core/index.js +23 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/internal.d.ts +17 -1
- package/dist/core/internal.js +18 -1
- package/dist/core/internal.js.map +1 -1
- package/dist/core/pool/image-header.d.ts +13 -2
- package/dist/core/pool/image-header.js +24 -5
- package/dist/core/pool/image-header.js.map +1 -1
- package/dist/core/pool/layout.d.ts +35 -1
- package/dist/core/pool/layout.js +51 -2
- package/dist/core/pool/layout.js.map +1 -1
- package/dist/core/pool/limits.d.ts +1 -0
- package/dist/core/pool/limits.js +1 -0
- package/dist/core/pool/limits.js.map +1 -1
- package/dist/core/pool/pool.d.ts +120 -15
- package/dist/core/pool/pool.js +255 -24
- package/dist/core/pool/pool.js.map +1 -1
- 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/{three → core}/sequence.d.ts +32 -2
- package/dist/{three → core}/sequence.js +24 -2
- 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 +33 -2
- package/dist/core/source/dense.js +121 -24
- package/dist/core/source/dense.js.map +1 -1
- 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 +59 -2
- package/dist/core/source/types.js.map +1 -1
- 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 +12 -3
- package/dist/core/types.js +6 -2
- package/dist/core/types.js.map +1 -1
- package/dist/core/wgsl/api.d.ts +29 -5
- package/dist/core/wgsl/api.js +110 -27
- package/dist/core/wgsl/api.js.map +1 -1
- package/dist/core/wgsl/generate.d.ts +8 -0
- package/dist/core/wgsl/generate.js +195 -22
- package/dist/core/wgsl/generate.js.map +1 -1
- 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 +5 -1
- package/dist/core/wgsl/level-set.js +11 -5
- package/dist/core/wgsl/level-set.js.map +1 -1
- 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 +2 -2
- package/dist/core/wgsl/pnanovdb.chunks.generated.js +15 -12
- package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -1
- package/dist/core/wgsl/types.d.ts +97 -3
- package/dist/core/wgsl/types.js.map +1 -1
- package/dist/three/coarse-first.d.ts +53 -8
- package/dist/three/coarse-first.js +24 -6
- package/dist/three/coarse-first.js.map +1 -1
- package/dist/three/compute.d.ts +12 -2
- package/dist/three/compute.js +16 -6
- package/dist/three/compute.js.map +1 -1
- package/dist/three/device.d.ts +7 -0
- package/dist/three/device.js +3 -0
- package/dist/three/device.js.map +1 -1
- 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 +64 -114
- package/dist/three/frame/emission-light.js +188 -567
- package/dist/three/frame/emission-light.js.map +1 -1
- package/dist/three/frame/index.d.ts +11 -31
- package/dist/three/frame/index.js +9 -29
- package/dist/three/frame/index.js.map +1 -1
- package/dist/three/frame/medium.d.ts +12 -0
- package/dist/three/frame/medium.js.map +1 -1
- package/dist/three/frame/renderer.d.ts +58 -454
- package/dist/three/frame/renderer.js +409 -1427
- package/dist/three/frame/renderer.js.map +1 -1
- package/dist/three/frame/spectrum.d.ts +0 -14
- package/dist/three/frame/spectrum.js +2 -23
- package/dist/three/frame/spectrum.js.map +1 -1
- package/dist/three/frame/three-internals.d.ts +3 -8
- package/dist/three/frame/three-internals.js +13 -11
- package/dist/three/frame/three-internals.js.map +1 -1
- package/dist/three/frame/volume-shadows.d.ts +93 -107
- package/dist/three/frame/volume-shadows.js +278 -631
- package/dist/three/frame/volume-shadows.js.map +1 -1
- package/dist/three/frame/volume.d.ts +91 -33
- package/dist/three/frame/volume.js +63 -51
- package/dist/three/frame/volume.js.map +1 -1
- package/dist/three/grid-node.d.ts +34 -1
- package/dist/three/grid-node.js +36 -1
- package/dist/three/grid-node.js.map +1 -1
- package/dist/three/index.d.ts +20 -11
- package/dist/three/index.js +21 -12
- package/dist/three/index.js.map +1 -1
- package/dist/three/internal.d.ts +14 -8
- package/dist/three/internal.js +11 -7
- package/dist/three/internal.js.map +1 -1
- package/dist/three/level-set-material.d.ts +81 -8
- package/dist/three/level-set-material.js +162 -125
- package/dist/three/level-set-material.js.map +1 -1
- 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 +141 -11
- package/dist/three/material.js +161 -18
- package/dist/three/material.js.map +1 -1
- package/dist/three/points.d.ts +60 -4
- package/dist/three/points.js +140 -9
- package/dist/three/points.js.map +1 -1
- package/dist/three/sparse-source.d.ts +49 -117
- package/dist/three/sparse-source.js +109 -580
- package/dist/three/sparse-source.js.map +1 -1
- package/dist/three/volume-source.d.ts +11 -156
- package/dist/three/volume-source.js +29 -272
- package/dist/three/volume-source.js.map +1 -1
- 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 +23 -4
- package/dist/tools/cpu/compute.js +35 -14
- package/dist/tools/cpu/compute.js.map +1 -1
- 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 +42 -3
- package/dist/tools/cpu/level-set.js +59 -7
- package/dist/tools/cpu/level-set.js.map +1 -1
- 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 +93 -2
- package/dist/tools/cpu/march.js +165 -14
- package/dist/tools/cpu/march.js.map +1 -1
- 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/read-value.d.ts +19 -6
- package/dist/tools/cpu/read-value.js +32 -17
- package/dist/tools/cpu/read-value.js.map +1 -1
- package/dist/tools/cpu/sample-trilinear.d.ts +17 -4
- package/dist/tools/cpu/sample-trilinear.js +19 -7
- package/dist/tools/cpu/sample-trilinear.js.map +1 -1
- package/dist/tools/cpu/stride-tables.d.ts +2 -2
- package/dist/tools/cpu/stride-tables.generated.d.ts +6 -5
- package/dist/tools/cpu/stride-tables.generated.js +7 -6
- package/dist/tools/cpu/stride-tables.generated.js.map +1 -1
- package/dist/tools/cpu/stride-tables.js +1 -1
- package/dist/tools/cpu/stride-tables.js.map +1 -1
- 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 +9 -0
- package/dist/tools/errors.js +9 -0
- package/dist/tools/errors.js.map +1 -1
- 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 +15 -0
- package/dist/tools/frame/blackbody.js +35 -0
- package/dist/tools/frame/blackbody.js.map +1 -1
- 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 +9 -0
- package/dist/tools/frame/emission.js +9 -1
- package/dist/tools/frame/emission.js.map +1 -1
- 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 +3 -2
- package/dist/tools/frame/environment.js +8 -4
- package/dist/tools/frame/environment.js.map +1 -1
- 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 +90 -0
- package/dist/tools/frame/grid.js +112 -13
- package/dist/tools/frame/grid.js.map +1 -1
- package/dist/tools/frame/index.d.ts +14 -0
- package/dist/tools/frame/index.js +45 -4
- package/dist/tools/frame/index.js.map +1 -1
- package/dist/tools/frame/medium.d.ts +16 -0
- package/dist/tools/frame/medium.js +3 -1
- package/dist/tools/frame/medium.js.map +1 -1
- package/dist/tools/frame/mie.d.ts +9 -0
- package/dist/tools/frame/mie.js +18 -0
- package/dist/tools/frame/mie.js.map +1 -1
- 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 +6 -5
- package/dist/tools/frame/neural-weights.js +234 -235
- package/dist/tools/frame/neural-weights.js.map +1 -1
- package/dist/tools/frame/neural.js +1 -1
- package/dist/tools/frame/neural.js.map +1 -1
- 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 +17 -0
- package/dist/tools/frame/pyramid-layout.js +47 -0
- package/dist/tools/frame/pyramid-layout.js.map +1 -1
- package/dist/tools/frame/shadows.d.ts +110 -0
- package/dist/tools/frame/shadows.js +286 -0
- package/dist/tools/frame/shadows.js.map +1 -1
- package/dist/tools/frame/sparse.d.ts +82 -0
- package/dist/tools/frame/sparse.js +242 -1
- package/dist/tools/frame/sparse.js.map +1 -1
- 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 +21 -2
- package/dist/tools/frame/spectral.js +30 -8
- package/dist/tools/frame/spectral.js.map +1 -1
- 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 +66 -15
- package/dist/tools/index.js +55 -11
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/internal.d.ts +58 -17
- package/dist/tools/internal.js +65 -11
- package/dist/tools/internal.js.map +1 -1
- package/dist/tools/nanovdb/build-from-vdb.d.ts +11 -2
- package/dist/tools/nanovdb/build-from-vdb.js +10 -2
- package/dist/tools/nanovdb/build-from-vdb.js.map +1 -1
- package/dist/tools/nanovdb/bytes.d.ts +17 -4
- package/dist/tools/nanovdb/bytes.js +46 -3
- package/dist/tools/nanovdb/bytes.js.map +1 -1
- package/dist/tools/nanovdb/coarse-first.d.ts +19 -3
- package/dist/tools/nanovdb/coarse-first.js +7 -1
- package/dist/tools/nanovdb/coarse-first.js.map +1 -1
- 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 +3 -1
- package/dist/tools/nanovdb/index.js +2 -1
- package/dist/tools/nanovdb/index.js.map +1 -1
- package/dist/tools/nanovdb/inspect.d.ts +10 -1
- package/dist/tools/nanovdb/inspect.js +8 -1
- package/dist/tools/nanovdb/inspect.js.map +1 -1
- package/dist/tools/nanovdb/leaf-codec.d.ts +35 -1
- package/dist/tools/nanovdb/leaf-codec.js +40 -4
- package/dist/tools/nanovdb/leaf-codec.js.map +1 -1
- package/dist/tools/nanovdb/quantize.d.ts +39 -10
- package/dist/tools/nanovdb/quantize.js +96 -44
- package/dist/tools/nanovdb/quantize.js.map +1 -1
- package/dist/tools/nanovdb/resample.d.ts +20 -3
- package/dist/tools/nanovdb/resample.js +20 -7
- package/dist/tools/nanovdb/resample.js.map +1 -1
- package/dist/tools/nanovdb/serialize.d.ts +34 -3
- package/dist/tools/nanovdb/serialize.js +51 -7
- package/dist/tools/nanovdb/serialize.js.map +1 -1
- package/dist/tools/nanovdb/stats.d.ts +34 -5
- package/dist/tools/nanovdb/stats.js +87 -11
- package/dist/tools/nanovdb/stats.js.map +1 -1
- package/dist/tools/nanovdb/transform.d.ts +4 -0
- package/dist/tools/nanovdb/transform.js +3 -0
- package/dist/tools/nanovdb/transform.js.map +1 -1
- package/dist/tools/nanovdb/tree.d.ts +14 -3
- package/dist/tools/nanovdb/tree.js +25 -13
- package/dist/tools/nanovdb/tree.js.map +1 -1
- package/dist/tools/nanovdb/write-nvdb.d.ts +47 -12
- package/dist/tools/nanovdb/write-nvdb.js +108 -28
- package/dist/tools/nanovdb/write-nvdb.js.map +1 -1
- package/dist/tools/nvdb-file.d.ts +77 -7
- package/dist/tools/nvdb-file.js +177 -20
- package/dist/tools/nvdb-file.js.map +1 -1
- package/dist/tools/nvdb-stream.d.ts +23 -7
- package/dist/tools/nvdb-stream.js +78 -34
- package/dist/tools/nvdb-stream.js.map +1 -1
- 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/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 +35 -5
- package/dist/tools/vdb/blosc.js +82 -26
- package/dist/tools/vdb/blosc.js.map +1 -1
- 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 +13 -3
- package/dist/tools/vdb/byte-reader.js +26 -4
- package/dist/tools/vdb/byte-reader.js.map +1 -1
- package/dist/tools/vdb/compression.d.ts +13 -5
- package/dist/tools/vdb/compression.js +13 -2
- package/dist/tools/vdb/compression.js.map +1 -1
- package/dist/tools/vdb/grid.js +8 -2
- package/dist/tools/vdb/grid.js.map +1 -1
- package/dist/tools/vdb/index.d.ts +2 -1
- package/dist/tools/vdb/index.js.map +1 -1
- 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.js +1 -1
- package/dist/tools/vdb/metadata.js.map +1 -1
- package/dist/tools/vdb/parse.d.ts +24 -2
- package/dist/tools/vdb/parse.js +102 -32
- package/dist/tools/vdb/parse.js.map +1 -1
- package/dist/tools/vdb/point-render-data.d.ts +49 -1
- package/dist/tools/vdb/point-render-data.js +91 -11
- package/dist/tools/vdb/point-render-data.js.map +1 -1
- package/dist/tools/vdb/points.d.ts +26 -0
- package/dist/tools/vdb/points.js +46 -5
- package/dist/tools/vdb/points.js.map +1 -1
- package/dist/tools/vdb/types.d.ts +59 -2
- package/dist/tools/vdb/types.js.map +1 -1
- package/dist/tools/wvdb/bake.d.ts +38 -9
- package/dist/tools/wvdb/bake.js +63 -13
- package/dist/tools/wvdb/bake.js.map +1 -1
- package/dist/tools/wvdb/dense.d.ts +80 -1
- package/dist/tools/wvdb/dense.js +67 -8
- package/dist/tools/wvdb/dense.js.map +1 -1
- package/dist/tools/wvdb/format.d.ts +59 -0
- package/dist/tools/wvdb/format.js +3 -0
- package/dist/tools/wvdb/format.js.map +1 -1
- package/dist/tools/wvdb/index.d.ts +1 -0
- package/dist/tools/wvdb/index.js +1 -0
- package/dist/tools/wvdb/index.js.map +1 -1
- package/dist/tools/wvdb/level-set.d.ts +10 -2
- package/dist/tools/wvdb/level-set.js.map +1 -1
- package/dist/tools/wvdb/nanovdb.d.ts +6 -1
- package/dist/tools/wvdb/nanovdb.js +5 -1
- package/dist/tools/wvdb/nanovdb.js.map +1 -1
- 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 +77 -1
- package/dist/tools/wvdb/read.js +30 -7
- package/dist/tools/wvdb/read.js.map +1 -1
- package/dist/tools/wvdb/write.d.ts +23 -1
- package/dist/tools/wvdb/write.js +8 -1
- package/dist/tools/wvdb/write.js.map +1 -1
- package/package.json +2 -1
- package/vendor/VENDOR.md +21 -6
- package/vendor/pnanovdb.wgsl +52 -14
- package/dist/three/frame/blackbody.d.ts +0 -42
- package/dist/three/frame/blackbody.js +0 -74
- package/dist/three/frame/blackbody.js.map +0 -1
- package/dist/three/frame/chunks.d.ts +0 -157
- package/dist/three/frame/chunks.js +0 -559
- package/dist/three/frame/chunks.js.map +0 -1
- package/dist/three/frame/density-material.d.ts +0 -53
- package/dist/three/frame/density-material.js +0 -353
- package/dist/three/frame/density-material.js.map +0 -1
- package/dist/three/frame/environment-grid-material.d.ts +0 -21
- package/dist/three/frame/environment-grid-material.js +0 -184
- package/dist/three/frame/environment-grid-material.js.map +0 -1
- package/dist/three/frame/environment-material.d.ts +0 -22
- package/dist/three/frame/environment-material.js +0 -87
- package/dist/three/frame/environment-material.js.map +0 -1
- package/dist/three/frame/grid-mip-material.d.ts +0 -12
- package/dist/three/frame/grid-mip-material.js +0 -61
- package/dist/three/frame/grid-mip-material.js.map +0 -1
- package/dist/three/frame/inject-material.d.ts +0 -56
- package/dist/three/frame/inject-material.js +0 -424
- package/dist/three/frame/inject-material.js.map +0 -1
- package/dist/three/frame/integrate-material.d.ts +0 -26
- package/dist/three/frame/integrate-material.js +0 -198
- package/dist/three/frame/integrate-material.js.map +0 -1
- package/dist/three/frame/layout.d.ts +0 -34
- package/dist/three/frame/layout.js +0 -48
- package/dist/three/frame/layout.js.map +0 -1
- package/dist/three/frame/lighting-material.d.ts +0 -41
- package/dist/three/frame/lighting-material.js +0 -257
- package/dist/three/frame/lighting-material.js.map +0 -1
- package/dist/three/frame/lights.d.ts +0 -11
- package/dist/three/frame/lights.js +0 -16
- package/dist/three/frame/lights.js.map +0 -1
- package/dist/three/frame/neural.d.ts +0 -14
- package/dist/three/frame/neural.js +0 -105
- package/dist/three/frame/neural.js.map +0 -1
- package/dist/three/frame/phase.d.ts +0 -44
- package/dist/three/frame/phase.js +0 -80
- package/dist/three/frame/phase.js.map +0 -1
- package/dist/three/frame/shadow-density-material.d.ts +0 -30
- package/dist/three/frame/shadow-density-material.js +0 -123
- package/dist/three/frame/shadow-density-material.js.map +0 -1
- package/dist/three/frame/temporal-material.d.ts +0 -29
- package/dist/three/frame/temporal-material.js +0 -152
- package/dist/three/frame/temporal-material.js.map +0 -1
- package/dist/three/frame/transmittance-material.d.ts +0 -31
- package/dist/three/frame/transmittance-material.js +0 -315
- package/dist/three/frame/transmittance-material.js.map +0 -1
- package/dist/three/frame/view.d.ts +0 -103
- package/dist/three/frame/view.js +0 -296
- package/dist/three/frame/view.js.map +0 -1
- package/dist/three/frame/volume-shadow-material.d.ts +0 -36
- package/dist/three/frame/volume-shadow-material.js +0 -128
- package/dist/three/frame/volume-shadow-material.js.map +0 -1
- package/dist/three/sequence.js.map +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lz4.ts — an LZ4 block compressor (K7.C1), so `writeNvdb({ codec: 'blosc' })` writes the LZ4 Blosc frames
|
|
3
|
+
* NanoVDB's `io::Internal::write` writes. The decoder is `decompressLz4Block` in `blosc.ts`.
|
|
4
|
+
*
|
|
5
|
+
* Ported from `LZ4_compress_generic_validated` of the LZ4 library OpenVDB v14.0.0 vendors
|
|
6
|
+
* (`ext/blosc/openvdb/ext/blosc/lz4/lz4.c`, LZ4 1.9.4), for the one case Blosc calls it with: one
|
|
7
|
+
* independent block (no dictionary, no stream state), `LZ4_compress_fast` on a 64-bit host:
|
|
8
|
+
*
|
|
9
|
+
* LZ4 Library
|
|
10
|
+
* Copyright (c) 2011-2020, Yann Collet
|
|
11
|
+
* License: BSD 2-Clause (see THIRD_PARTY_NOTICES.md)
|
|
12
|
+
*
|
|
13
|
+
* The match finder, its hash functions (`LZ4_hash4` for inputs under 64 KiB + 11, the 64-bit
|
|
14
|
+
* `LZ4_hash5` otherwise), the 2^14-byte table (LZ4_MEMORY_USAGE 14), the skip schedule
|
|
15
|
+
* (`acceleration << 6`), the backward catch-up, and the conservative `limitedOutput` budget checks are
|
|
16
|
+
* the C code's, so a block compresses to the same bytes as native LZ4 (DIVERGES V164): Blosc then stores
|
|
17
|
+
* a split raw exactly where native does. Pointers become indices into `src`; a 32-bit host's `byPtr`
|
|
18
|
+
* table (and its `LZ4_hash4` on large inputs) is not ported.
|
|
19
|
+
*/
|
|
20
|
+
/** `LZ4_MAX_INPUT_SIZE`. */
|
|
21
|
+
export declare const LZ4_MAX_INPUT_SIZE = 2113929216;
|
|
22
|
+
/** `LZ4_compressBound`: the largest output of a block of `n` bytes (0 past `LZ4_MAX_INPUT_SIZE`). */
|
|
23
|
+
export declare function lz4CompressBound(n: number): number;
|
|
24
|
+
/**
|
|
25
|
+
* Compresses `src` into one raw LZ4 block (no frame) at the start of `dest`, as `LZ4_compress_fast(src,
|
|
26
|
+
* dest, src.length, dest.length, acceleration)` does, and returns the block's length, or 0 when it does
|
|
27
|
+
* not fit in `dest` (LZ4's limited-output checks, which give up a few bytes before the exact end, apply
|
|
28
|
+
* whenever `dest` is shorter than {@link lz4CompressBound}). An empty input is the one-byte block `0`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function compressLz4Block(src: Uint8Array, dest: Uint8Array, acceleration?: number): number;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* lz4.ts — an LZ4 block compressor (K7.C1), so `writeNvdb({ codec: 'blosc' })` writes the LZ4 Blosc frames
|
|
3
|
+
* NanoVDB's `io::Internal::write` writes. The decoder is `decompressLz4Block` in `blosc.ts`.
|
|
4
|
+
*
|
|
5
|
+
* Ported from `LZ4_compress_generic_validated` of the LZ4 library OpenVDB v14.0.0 vendors
|
|
6
|
+
* (`ext/blosc/openvdb/ext/blosc/lz4/lz4.c`, LZ4 1.9.4), for the one case Blosc calls it with: one
|
|
7
|
+
* independent block (no dictionary, no stream state), `LZ4_compress_fast` on a 64-bit host:
|
|
8
|
+
*
|
|
9
|
+
* LZ4 Library
|
|
10
|
+
* Copyright (c) 2011-2020, Yann Collet
|
|
11
|
+
* License: BSD 2-Clause (see THIRD_PARTY_NOTICES.md)
|
|
12
|
+
*
|
|
13
|
+
* The match finder, its hash functions (`LZ4_hash4` for inputs under 64 KiB + 11, the 64-bit
|
|
14
|
+
* `LZ4_hash5` otherwise), the 2^14-byte table (LZ4_MEMORY_USAGE 14), the skip schedule
|
|
15
|
+
* (`acceleration << 6`), the backward catch-up, and the conservative `limitedOutput` budget checks are
|
|
16
|
+
* the C code's, so a block compresses to the same bytes as native LZ4 (DIVERGES V164): Blosc then stores
|
|
17
|
+
* a split raw exactly where native does. Pointers become indices into `src`; a 32-bit host's `byPtr`
|
|
18
|
+
* table (and its `LZ4_hash4` on large inputs) is not ported.
|
|
19
|
+
*/
|
|
20
|
+
/** `LZ4_MAX_INPUT_SIZE`. */
|
|
21
|
+
export const LZ4_MAX_INPUT_SIZE = 0x7e000000;
|
|
22
|
+
const MINMATCH = 4;
|
|
23
|
+
const LASTLITERALS = 5;
|
|
24
|
+
const MFLIMIT = 12;
|
|
25
|
+
const LZ4_MIN_LENGTH = MFLIMIT + 1;
|
|
26
|
+
const ML_MASK = 15;
|
|
27
|
+
const RUN_MASK = 15;
|
|
28
|
+
/** `LZ4_64Klimit`: inputs below it use the 16-bit table and `LZ4_hash4`. */
|
|
29
|
+
const LZ4_64K_LIMIT = 65536 + (MFLIMIT - 1);
|
|
30
|
+
const LZ4_SKIP_TRIGGER = 6;
|
|
31
|
+
const LZ4_DISTANCE_MAX = 65535;
|
|
32
|
+
const LZ4_ACCELERATION_MAX = 65537;
|
|
33
|
+
/** LZ4_MEMORY_USAGE 14: 2^12 u32 slots, or 2^13 u16 slots for small inputs. */
|
|
34
|
+
const LZ4_HASHLOG = 12;
|
|
35
|
+
const PRIME4 = 2654435761 | 0;
|
|
36
|
+
/** `prime5bytes` = 889523592379 = 0xCF_1BBCDCBB, split in 32-bit halves. */
|
|
37
|
+
const PRIME5_LO = 0x1bbcdcbb;
|
|
38
|
+
const PRIME5_HI = 0xcf;
|
|
39
|
+
let table32 = null;
|
|
40
|
+
let table16 = null;
|
|
41
|
+
/** `LZ4_compressBound`: the largest output of a block of `n` bytes (0 past `LZ4_MAX_INPUT_SIZE`). */
|
|
42
|
+
export function lz4CompressBound(n) {
|
|
43
|
+
return n > LZ4_MAX_INPUT_SIZE || n < 0 ? 0 : n + Math.floor(n / 255) + 16;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Compresses `src` into one raw LZ4 block (no frame) at the start of `dest`, as `LZ4_compress_fast(src,
|
|
47
|
+
* dest, src.length, dest.length, acceleration)` does, and returns the block's length, or 0 when it does
|
|
48
|
+
* not fit in `dest` (LZ4's limited-output checks, which give up a few bytes before the exact end, apply
|
|
49
|
+
* whenever `dest` is shorter than {@link lz4CompressBound}). An empty input is the one-byte block `0`.
|
|
50
|
+
*/
|
|
51
|
+
export function compressLz4Block(src, dest, acceleration = 1) {
|
|
52
|
+
const inputSize = src.length;
|
|
53
|
+
if (inputSize > LZ4_MAX_INPUT_SIZE)
|
|
54
|
+
return 0;
|
|
55
|
+
let accel = Math.floor(acceleration);
|
|
56
|
+
if (!(accel >= 1))
|
|
57
|
+
accel = 1;
|
|
58
|
+
if (accel > LZ4_ACCELERATION_MAX)
|
|
59
|
+
accel = LZ4_ACCELERATION_MAX;
|
|
60
|
+
const limited = dest.length < lz4CompressBound(inputSize);
|
|
61
|
+
const olimit = dest.length;
|
|
62
|
+
if (inputSize === 0) {
|
|
63
|
+
if (limited && olimit <= 0)
|
|
64
|
+
return 0;
|
|
65
|
+
dest[0] = 0;
|
|
66
|
+
return 1;
|
|
67
|
+
}
|
|
68
|
+
const small = inputSize < LZ4_64K_LIMIT;
|
|
69
|
+
let t16 = null;
|
|
70
|
+
let t32 = null;
|
|
71
|
+
if (small) {
|
|
72
|
+
t16 = table16 ??= new Uint16Array(1 << (LZ4_HASHLOG + 1));
|
|
73
|
+
t16.fill(0);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
t32 = table32 ??= new Uint32Array(1 << LZ4_HASHLOG);
|
|
77
|
+
t32.fill(0);
|
|
78
|
+
}
|
|
79
|
+
const hash = small
|
|
80
|
+
? (p) => Math.imul(src[p] | (src[p + 1] << 8) | (src[p + 2] << 16) | (src[p + 3] << 24), PRIME4) >>> (32 - (LZ4_HASHLOG + 1))
|
|
81
|
+
: (p) => {
|
|
82
|
+
// ((read64(p) << 24) * prime5bytes) >> (64 - 12): only bytes p..p+4 reach the product.
|
|
83
|
+
// x = hi:lo with lo = b0 << 24, hi = b1 | b2 << 8 | b3 << 16 | b4 << 24.
|
|
84
|
+
const b0 = src[p];
|
|
85
|
+
const hi = src[p + 1] | (src[p + 2] << 8) | (src[p + 3] << 16) | (src[p + 4] << 24);
|
|
86
|
+
const carry = Math.floor((b0 * PRIME5_LO) / 256); // high word of (b0 << 24) * PRIME5_LO (< 2^37 / 2^8)
|
|
87
|
+
const top = (Math.imul(hi, PRIME5_LO) + Math.imul(b0 << 24, PRIME5_HI) + carry) | 0;
|
|
88
|
+
return top >>> (32 - LZ4_HASHLOG);
|
|
89
|
+
};
|
|
90
|
+
const get = small ? (h) => t16[h] : (h) => t32[h];
|
|
91
|
+
const put = small
|
|
92
|
+
? (idx, h) => {
|
|
93
|
+
t16[h] = idx;
|
|
94
|
+
}
|
|
95
|
+
: (idx, h) => {
|
|
96
|
+
t32[h] = idx;
|
|
97
|
+
};
|
|
98
|
+
const read32 = (p) => src[p] | (src[p + 1] << 8) | (src[p + 2] << 16) | (src[p + 3] << 24);
|
|
99
|
+
const iend = inputSize;
|
|
100
|
+
const mflimitPlusOne = iend - MFLIMIT + 1;
|
|
101
|
+
const matchlimit = iend - LASTLITERALS;
|
|
102
|
+
let anchor = 0;
|
|
103
|
+
let op = 0;
|
|
104
|
+
let ip = 0;
|
|
105
|
+
if (inputSize >= LZ4_MIN_LENGTH) {
|
|
106
|
+
put(0, hash(0));
|
|
107
|
+
ip = 1;
|
|
108
|
+
let forwardH = hash(ip);
|
|
109
|
+
mainLoop: for (;;) {
|
|
110
|
+
let match = 0;
|
|
111
|
+
// Find a match.
|
|
112
|
+
{
|
|
113
|
+
let forwardIp = ip;
|
|
114
|
+
let step = 1;
|
|
115
|
+
let searchMatchNb = accel << LZ4_SKIP_TRIGGER;
|
|
116
|
+
for (;;) {
|
|
117
|
+
const h = forwardH;
|
|
118
|
+
const current = forwardIp;
|
|
119
|
+
const matchIndex = get(h);
|
|
120
|
+
ip = forwardIp;
|
|
121
|
+
forwardIp += step;
|
|
122
|
+
step = searchMatchNb++ >> LZ4_SKIP_TRIGGER;
|
|
123
|
+
if (forwardIp > mflimitPlusOne)
|
|
124
|
+
break mainLoop;
|
|
125
|
+
match = matchIndex;
|
|
126
|
+
forwardH = hash(forwardIp);
|
|
127
|
+
put(current, h);
|
|
128
|
+
if (!small && matchIndex + LZ4_DISTANCE_MAX < current)
|
|
129
|
+
continue; // too far
|
|
130
|
+
if (read32(match) === read32(ip))
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// Catch up.
|
|
135
|
+
while (ip > anchor && match > 0 && src[ip - 1] === src[match - 1]) {
|
|
136
|
+
ip--;
|
|
137
|
+
match--;
|
|
138
|
+
}
|
|
139
|
+
// Encode literals.
|
|
140
|
+
let token;
|
|
141
|
+
{
|
|
142
|
+
const litLength = ip - anchor;
|
|
143
|
+
token = op++;
|
|
144
|
+
if (limited && op + litLength + (2 + 1 + LASTLITERALS) + Math.floor(litLength / 255) > olimit)
|
|
145
|
+
return 0;
|
|
146
|
+
if (litLength >= RUN_MASK) {
|
|
147
|
+
let len = litLength - RUN_MASK;
|
|
148
|
+
dest[token] = RUN_MASK << 4;
|
|
149
|
+
for (; len >= 255; len -= 255)
|
|
150
|
+
dest[op++] = 255;
|
|
151
|
+
dest[op++] = len;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
dest[token] = litLength << 4;
|
|
155
|
+
}
|
|
156
|
+
dest.set(src.subarray(anchor, ip), op);
|
|
157
|
+
op += litLength;
|
|
158
|
+
}
|
|
159
|
+
// _next_match (re-entered with a zero-literal token while the next position matches).
|
|
160
|
+
for (;;) {
|
|
161
|
+
const offset = ip - match;
|
|
162
|
+
dest[op] = offset & 0xff;
|
|
163
|
+
dest[op + 1] = offset >>> 8;
|
|
164
|
+
op += 2;
|
|
165
|
+
let matchCode = 0;
|
|
166
|
+
{
|
|
167
|
+
let a = ip + MINMATCH;
|
|
168
|
+
let b = match + MINMATCH;
|
|
169
|
+
while (a < matchlimit && src[a] === src[b]) {
|
|
170
|
+
a++;
|
|
171
|
+
b++;
|
|
172
|
+
}
|
|
173
|
+
matchCode = a - (ip + MINMATCH);
|
|
174
|
+
}
|
|
175
|
+
ip += matchCode + MINMATCH;
|
|
176
|
+
if (limited && op + (1 + LASTLITERALS) + Math.floor((matchCode + 240) / 255) > olimit)
|
|
177
|
+
return 0;
|
|
178
|
+
if (matchCode >= ML_MASK) {
|
|
179
|
+
dest[token] = dest[token] + ML_MASK;
|
|
180
|
+
matchCode -= ML_MASK;
|
|
181
|
+
for (; matchCode >= 255; matchCode -= 255)
|
|
182
|
+
dest[op++] = 255;
|
|
183
|
+
dest[op++] = matchCode;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
dest[token] = dest[token] + matchCode;
|
|
187
|
+
}
|
|
188
|
+
anchor = ip;
|
|
189
|
+
if (ip >= mflimitPlusOne)
|
|
190
|
+
break mainLoop;
|
|
191
|
+
// Fill table.
|
|
192
|
+
put(ip - 2, hash(ip - 2));
|
|
193
|
+
// Test next position.
|
|
194
|
+
const h = hash(ip);
|
|
195
|
+
const current = ip;
|
|
196
|
+
const matchIndex = get(h);
|
|
197
|
+
match = matchIndex;
|
|
198
|
+
put(current, h);
|
|
199
|
+
if ((small || matchIndex + LZ4_DISTANCE_MAX >= current) && read32(match) === read32(ip)) {
|
|
200
|
+
token = op++;
|
|
201
|
+
dest[token] = 0;
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
// Prepare next loop.
|
|
207
|
+
forwardH = hash(++ip);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// Last literals.
|
|
211
|
+
const lastRun = iend - anchor;
|
|
212
|
+
if (limited && op + lastRun + 1 + Math.floor((lastRun + 255 - RUN_MASK) / 255) > olimit)
|
|
213
|
+
return 0;
|
|
214
|
+
if (lastRun >= RUN_MASK) {
|
|
215
|
+
let acc = lastRun - RUN_MASK;
|
|
216
|
+
dest[op++] = RUN_MASK << 4;
|
|
217
|
+
for (; acc >= 255; acc -= 255)
|
|
218
|
+
dest[op++] = 255;
|
|
219
|
+
dest[op++] = acc;
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
dest[op++] = lastRun << 4;
|
|
223
|
+
}
|
|
224
|
+
dest.set(src.subarray(anchor, iend), op);
|
|
225
|
+
op += lastRun;
|
|
226
|
+
return op;
|
|
227
|
+
}
|
|
228
|
+
//# sourceMappingURL=lz4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lz4.js","sourceRoot":"","sources":["../../../src/tools/vdb/lz4.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,4BAA4B;AAC5B,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC;AAC7C,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,YAAY,GAAG,CAAC,CAAC;AACvB,MAAM,OAAO,GAAG,EAAE,CAAC;AACnB,MAAM,cAAc,GAAG,OAAO,GAAG,CAAC,CAAC;AACnC,MAAM,OAAO,GAAG,EAAE,CAAC;AACnB,MAAM,QAAQ,GAAG,EAAE,CAAC;AACpB,4EAA4E;AAC5E,MAAM,aAAa,GAAG,KAAK,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;AAC5C,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAC/B,MAAM,oBAAoB,GAAG,KAAK,CAAC;AACnC,+EAA+E;AAC/E,MAAM,WAAW,GAAG,EAAE,CAAC;AAEvB,MAAM,MAAM,GAAG,UAAU,GAAG,CAAC,CAAC;AAC9B,4EAA4E;AAC5E,MAAM,SAAS,GAAG,UAAU,CAAC;AAC7B,MAAM,SAAS,GAAG,IAAI,CAAC;AAEvB,IAAI,OAAO,GAAuB,IAAI,CAAC;AACvC,IAAI,OAAO,GAAuB,IAAI,CAAC;AAEvC,qGAAqG;AACrG,MAAM,UAAU,gBAAgB,CAAC,CAAS;IACxC,OAAO,CAAC,GAAG,kBAAkB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC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oVDB's `io::Internal::write` writes. The decoder is `decompressLz4Block` in `blosc.ts`.\n *\n * Ported from `LZ4_compress_generic_validated` of the LZ4 library OpenVDB v14.0.0 vendors\n * (`ext/blosc/openvdb/ext/blosc/lz4/lz4.c`, LZ4 1.9.4), for the one case Blosc calls it with: one\n * independent block (no dictionary, no stream state), `LZ4_compress_fast` on a 64-bit host:\n *\n * LZ4 Library\n * Copyright (c) 2011-2020, Yann Collet\n * License: BSD 2-Clause (see THIRD_PARTY_NOTICES.md)\n *\n * The match finder, its hash functions (`LZ4_hash4` for inputs under 64 KiB + 11, the 64-bit\n * `LZ4_hash5` otherwise), the 2^14-byte table (LZ4_MEMORY_USAGE 14), the skip schedule\n * (`acceleration << 6`), the backward catch-up, and the conservative `limitedOutput` budget checks are\n * the C code's, so a block compresses to the same bytes as native LZ4 (DIVERGES V164): Blosc then stores\n * a split raw exactly where native does. Pointers become indices into `src`; a 32-bit host's `byPtr`\n * table (and its `LZ4_hash4` on large inputs) is not ported.\n */\n\n/** `LZ4_MAX_INPUT_SIZE`. */\nexport const LZ4_MAX_INPUT_SIZE = 0x7e000000;\nconst MINMATCH = 4;\nconst LASTLITERALS = 5;\nconst MFLIMIT = 12;\nconst LZ4_MIN_LENGTH = MFLIMIT + 1;\nconst ML_MASK = 15;\nconst RUN_MASK = 15;\n/** `LZ4_64Klimit`: inputs below it use the 16-bit table and `LZ4_hash4`. */\nconst LZ4_64K_LIMIT = 65536 + (MFLIMIT - 1);\nconst LZ4_SKIP_TRIGGER = 6;\nconst LZ4_DISTANCE_MAX = 65535;\nconst LZ4_ACCELERATION_MAX = 65537;\n/** LZ4_MEMORY_USAGE 14: 2^12 u32 slots, or 2^13 u16 slots for small inputs. */\nconst LZ4_HASHLOG = 12;\n\nconst PRIME4 = 2654435761 | 0;\n/** `prime5bytes` = 889523592379 = 0xCF_1BBCDCBB, split in 32-bit halves. */\nconst PRIME5_LO = 0x1bbcdcbb;\nconst PRIME5_HI = 0xcf;\n\nlet table32: Uint32Array | null = null;\nlet table16: Uint16Array | null = null;\n\n/** `LZ4_compressBound`: the largest output of a block of `n` bytes (0 past `LZ4_MAX_INPUT_SIZE`). */\nexport function lz4CompressBound(n: number): number {\n return n > LZ4_MAX_INPUT_SIZE || n < 0 ? 0 : n + Math.floor(n / 255) + 16;\n}\n\n/**\n * Compresses `src` into one raw LZ4 block (no frame) at the start of `dest`, as `LZ4_compress_fast(src,\n * dest, src.length, dest.length, acceleration)` does, and returns the block's length, or 0 when it does\n * not fit in `dest` (LZ4's limited-output checks, which give up a few bytes before the exact end, apply\n * whenever `dest` is shorter than {@link lz4CompressBound}). An empty input is the one-byte block `0`.\n */\nexport function compressLz4Block(src: Uint8Array, dest: Uint8Array, acceleration = 1): number {\n const inputSize = src.length;\n if (inputSize > LZ4_MAX_INPUT_SIZE) return 0;\n let accel = Math.floor(acceleration);\n if (!(accel >= 1)) accel = 1;\n if (accel > LZ4_ACCELERATION_MAX) accel = LZ4_ACCELERATION_MAX;\n const limited = dest.length < lz4CompressBound(inputSize);\n const olimit = dest.length;\n if (inputSize === 0) {\n if (limited && olimit <= 0) return 0;\n dest[0] = 0;\n return 1;\n }\n\n const small = inputSize < LZ4_64K_LIMIT;\n let t16: Uint16Array | null = null;\n let t32: Uint32Array | null = null;\n if (small) {\n t16 = table16 ??= new Uint16Array(1 << (LZ4_HASHLOG + 1));\n t16.fill(0);\n } else {\n t32 = table32 ??= new Uint32Array(1 << LZ4_HASHLOG);\n t32.fill(0);\n }\n const hash = small\n ? (p: number): number =>\n Math.imul(src[p]! | (src[p + 1]! << 8) | (src[p + 2]! << 16) | (src[p + 3]! << 24), PRIME4) >>> (32 - (LZ4_HASHLOG + 1))\n : (p: number): number => {\n // ((read64(p) << 24) * prime5bytes) >> (64 - 12): only bytes p..p+4 reach the product.\n // x = hi:lo with lo = b0 << 24, hi = b1 | b2 << 8 | b3 << 16 | b4 << 24.\n const b0 = src[p]!;\n const hi = src[p + 1]! | (src[p + 2]! << 8) | (src[p + 3]! << 16) | (src[p + 4]! << 24);\n const carry = Math.floor((b0 * PRIME5_LO) / 256); // high word of (b0 << 24) * PRIME5_LO (< 2^37 / 2^8)\n const top = (Math.imul(hi, PRIME5_LO) + Math.imul(b0 << 24, PRIME5_HI) + carry) | 0;\n return top >>> (32 - LZ4_HASHLOG);\n };\n const get = small ? (h: number): number => t16![h]! : (h: number): number => t32![h]!;\n const put = small\n ? (idx: number, h: number): void => {\n t16![h] = idx;\n }\n : (idx: number, h: number): void => {\n t32![h] = idx;\n };\n const read32 = (p: number): number => src[p]! | (src[p + 1]! << 8) | (src[p + 2]! << 16) | (src[p + 3]! << 24);\n\n const iend = inputSize;\n const mflimitPlusOne = iend - MFLIMIT + 1;\n const matchlimit = iend - LASTLITERALS;\n let anchor = 0;\n let op = 0;\n let ip = 0;\n\n if (inputSize >= LZ4_MIN_LENGTH) {\n put(0, hash(0));\n ip = 1;\n let forwardH = hash(ip);\n\n mainLoop: for (;;) {\n let match = 0;\n // Find a match.\n {\n let forwardIp = ip;\n let step = 1;\n let searchMatchNb = accel << LZ4_SKIP_TRIGGER;\n for (;;) {\n const h = forwardH;\n const current = forwardIp;\n const matchIndex = get(h);\n ip = forwardIp;\n forwardIp += step;\n step = searchMatchNb++ >> LZ4_SKIP_TRIGGER;\n if (forwardIp > mflimitPlusOne) break mainLoop;\n match = matchIndex;\n forwardH = hash(forwardIp);\n put(current, h);\n if (!small && matchIndex + LZ4_DISTANCE_MAX < current) continue; // too far\n if (read32(match) === read32(ip)) break;\n }\n }\n\n // Catch up.\n while (ip > anchor && match > 0 && src[ip - 1] === src[match - 1]) {\n ip--;\n match--;\n }\n\n // Encode literals.\n let token: number;\n {\n const litLength = ip - anchor;\n token = op++;\n if (limited && op + litLength + (2 + 1 + LASTLITERALS) + Math.floor(litLength / 255) > olimit) return 0;\n if (litLength >= RUN_MASK) {\n let len = litLength - RUN_MASK;\n dest[token] = RUN_MASK << 4;\n for (; len >= 255; len -= 255) dest[op++] = 255;\n dest[op++] = len;\n } else {\n dest[token] = litLength << 4;\n }\n dest.set(src.subarray(anchor, ip), op);\n op += litLength;\n }\n\n // _next_match (re-entered with a zero-literal token while the next position matches).\n for (;;) {\n const offset = ip - match;\n dest[op] = offset & 0xff;\n dest[op + 1] = offset >>> 8;\n op += 2;\n\n let matchCode = 0;\n {\n let a = ip + MINMATCH;\n let b = match + MINMATCH;\n while (a < matchlimit && src[a] === src[b]) {\n a++;\n b++;\n }\n matchCode = a - (ip + MINMATCH);\n }\n ip += matchCode + MINMATCH;\n if (limited && op + (1 + LASTLITERALS) + Math.floor((matchCode + 240) / 255) > olimit) return 0;\n if (matchCode >= ML_MASK) {\n dest[token] = dest[token]! + ML_MASK;\n matchCode -= ML_MASK;\n for (; matchCode >= 255; matchCode -= 255) dest[op++] = 255;\n dest[op++] = matchCode;\n } else {\n dest[token] = dest[token]! + matchCode;\n }\n\n anchor = ip;\n if (ip >= mflimitPlusOne) break mainLoop;\n\n // Fill table.\n put(ip - 2, hash(ip - 2));\n\n // Test next position.\n const h = hash(ip);\n const current = ip;\n const matchIndex = get(h);\n match = matchIndex;\n put(current, h);\n if ((small || matchIndex + LZ4_DISTANCE_MAX >= current) && read32(match) === read32(ip)) {\n token = op++;\n dest[token] = 0;\n continue;\n }\n break;\n }\n\n // Prepare next loop.\n forwardH = hash(++ip);\n }\n }\n\n // Last literals.\n const lastRun = iend - anchor;\n if (limited && op + lastRun + 1 + Math.floor((lastRun + 255 - RUN_MASK) / 255) > olimit) return 0;\n if (lastRun >= RUN_MASK) {\n let acc = lastRun - RUN_MASK;\n dest[op++] = RUN_MASK << 4;\n for (; acc >= 255; acc -= 255) dest[op++] = 255;\n dest[op++] = acc;\n } else {\n dest[op++] = lastRun << 4;\n }\n dest.set(src.subarray(anchor, iend), op);\n op += lastRun;\n return op;\n}\n"]}
|
|
@@ -9,7 +9,7 @@ function readMetadataValue(reader, type, byteLength) {
|
|
|
9
9
|
let value;
|
|
10
10
|
switch (type) {
|
|
11
11
|
case "string":
|
|
12
|
-
value = reader.
|
|
12
|
+
value = reader.textOf(byteLength); // UTF-8, latin1 fallback (K7.17)
|
|
13
13
|
break;
|
|
14
14
|
case "bool":
|
|
15
15
|
value = reader.bool();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/tools/vdb/metadata.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,SAAS,iBAAiB,CAAC,MAAkB,EAAE,IAAY,EAAE,UAAkB;IAC7E,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC;IACzB,IAAI,KAAoB,CAAC;IACzB,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ;YACX,KAAK,GAAG,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../../src/tools/vdb/metadata.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAYH,SAAS,iBAAiB,CAAC,MAAkB,EAAE,IAAY,EAAE,UAAkB;IAC7E,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC;IACzB,IAAI,KAAoB,CAAC;IACzB,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ;YACX,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,iCAAiC;YACpE,MAAM;QACR,KAAK,MAAM;YACT,KAAK,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;YACtB,MAAM;QACR,KAAK,OAAO;YACV,KAAK,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;YACrB,MAAM;QACR,KAAK,OAAO;YACV,KAAK,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,6DAA6D;YACnF,MAAM;QACR,KAAK,OAAO;YACV,KAAK,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;YACrB,MAAM;QACR,KAAK,QAAQ;YACX,KAAK,GAAG,MAAM,CAAC,GAAG,EAAE,CAAC;YACrB,MAAM;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D,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * metadata.ts — the generic `(name, type, byteLength, value)` metadata map\n * used both at file scope (`OpenVDBReader.readHeader`) and per-grid scope\n * (`GridDescriptor.readMetadata`) — same on-disk encoding both times, per\n * both format references.\n */\n\nimport type { ByteReader } from \"./byte-reader.js\";\n\nexport type MetadataValue =\n | string\n | boolean\n | number\n | bigint\n | [number, number, number]\n | Uint8Array;\n\nfunction readMetadataValue(reader: ByteReader, type: string, byteLength: number): MetadataValue {\n const start = reader.pos;\n let value: MetadataValue;\n switch (type) {\n case \"string\":\n value = reader.textOf(byteLength); // UTF-8, latin1 fallback (K7.17)\n break;\n case \"bool\":\n value = reader.bool();\n break;\n case \"int32\":\n value = reader.i32();\n break;\n case \"int64\":\n value = reader.u64(); // stored/consumed as bigint; real files use plain magnitudes\n break;\n case \"float\":\n value = reader.f32();\n break;\n case \"double\":\n value = reader.f64();\n break;\n case \"vec3i\":\n value = reader.vec3i();\n break;\n case \"vec3s\":\n value = [reader.f32(), reader.f32(), reader.f32()];\n break;\n case \"vec3d\":\n value = reader.vec3d();\n break;\n default:\n // Unknown metadata type (e.g. exotic user metadata) — keep the raw\n // bytes rather than failing the whole parse over cosmetic metadata.\n value = reader.bytes_(byteLength).slice();\n break;\n }\n const consumed = reader.pos - start;\n if (consumed !== byteLength) {\n // Some types (e.g. \"string\") legitimately consume exactly byteLength;\n // fixed-size types should too. If not, trust the declared length so a\n // format quirk here doesn't desync the rest of the stream.\n reader.seek(start + byteLength);\n }\n return value;\n}\n\n/**\n * Reads a `count`-prefixed `(name, type, len, value)*` metadata map.\n *\n * The result has a null prototype (K4.14): metadata names come from the file, and a\n * name like `__proto__` must become an ordinary own key, never write through to a\n * prototype. Use `Object.hasOwn` / `in` / `Object.keys`; `.hasOwnProperty` and\n * `.toString` are not available on it.\n */\nexport function readMetadataMap(reader: ByteReader): Record<string, MetadataValue> {\n const count = reader.u32();\n const map: Record<string, MetadataValue> = Object.create(null) as Record<string, MetadataValue>;\n for (let i = 0; i < count; i++) {\n const name = reader.string();\n const type = reader.string();\n const byteLength = reader.u32();\n map[name] = readMetadataValue(reader, type, byteLength);\n }\n return map;\n}\n"]}
|
|
@@ -21,5 +21,27 @@
|
|
|
21
21
|
* multi-grid files, and it's cheap insurance against any of our own
|
|
22
22
|
* byte-accounting bugs desyncing the stream for the next grid.
|
|
23
23
|
*/
|
|
24
|
-
import type { VdbFile } from "./types.js";
|
|
25
|
-
export
|
|
24
|
+
import type { VdbFile, VdbGridDescriptor } from "./types.js";
|
|
25
|
+
export interface ParseVdbOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Called for every grid once its header (name, type, metadata, transform) is read, before its tree. Return `false`
|
|
28
|
+
* to skip decoding that grid; it still appears in `VdbFile.descriptors`. Passing `select` also switches the
|
|
29
|
+
* parser to report mode: a grid it cannot decode (unsupported value type, tree layout, transform or instancing)
|
|
30
|
+
* is listed with `descriptor.unsupported` set and skipped, instead of throwing. `select` is not called for it.
|
|
31
|
+
*
|
|
32
|
+
* Without `select`, every grid is decoded and an unsupported grid throws `VDBUnsupportedError`, as before.
|
|
33
|
+
* `select: () => false` is a cheap listing pass: no tree is decoded or decompressed.
|
|
34
|
+
*/
|
|
35
|
+
select?: (descriptor: VdbGridDescriptor) => boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Parses an OpenVDB `.vdb` file (float, half, vec3 and point data grids) into trees you can read, iterate or
|
|
39
|
+
* convert to NanoVDB. Returns the decoded `grids` and a `descriptors` entry for every grid in the file.
|
|
40
|
+
* Throws `VdbFormatError` for a malformed buffer, `VDBUnsupportedError` for unsupported constructs (without
|
|
41
|
+
* `select`; with it, an unsupported grid is reported in its descriptor). See {@link ParseVdbOptions.select} to list
|
|
42
|
+
* grids cheaply or decode only some of them.
|
|
43
|
+
*
|
|
44
|
+
* @param buffer The file's bytes.
|
|
45
|
+
* @param options `select`: which grids to decode.
|
|
46
|
+
*/
|
|
47
|
+
export declare function parseVdb(buffer: ArrayBuffer, options?: ParseVdbOptions): VdbFile;
|
package/dist/tools/vdb/parse.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* byte-accounting bugs desyncing the stream for the next grid.
|
|
23
23
|
*/
|
|
24
24
|
import { ByteReader } from "./byte-reader.js";
|
|
25
|
-
import { compressionFromBits, FLOAT_FORMAT, PTDATAIDX32_FORMAT, VEC3D_FORMAT, VEC3I_FORMAT, VEC3S_FORMAT, } from "./compression.js";
|
|
25
|
+
import { compressionFromBits, FLOAT_FORMAT, HALF_FORMAT, PTDATAIDX32_FORMAT, VEC3D_FORMAT, VEC3I_FORMAT, VEC3S_FORMAT, } from "./compression.js";
|
|
26
26
|
import { VdbFormatError, VDBUnsupportedError } from "./errors.js";
|
|
27
27
|
import { createVdbGrid } from "./grid.js";
|
|
28
28
|
import { readMetadataMap } from "./metadata.js";
|
|
@@ -30,20 +30,38 @@ import { readTransform } from "./transform.js";
|
|
|
30
30
|
import { readTree } from "./tree.js";
|
|
31
31
|
const MAGIC_LOW = 0x56444220; // 'V','D','B',' ' read little-endian, low 32 bits
|
|
32
32
|
const MIN_SUPPORTED_VERSION = 213; // OPENVDB_FILE_VERSION_ROOTNODE_MAP
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* OPENVDB_FILE_VERSION (225, `OPENVDB_FILE_VERSION_HALF_GRID`), still current in OpenVDB v14.0.0.
|
|
35
|
+
* A newer file fails with `VDBUnsupportedError` before anything after the header is read: a
|
|
36
|
+
* future layout could misparse silently. OpenVDB 13.2+ warns for 226-299 and rejects 300+
|
|
37
|
+
* (`OPENVDB_UNSUPPORTED_FILE_VERSION`); we reject from 226 (DIVERGES V71).
|
|
38
|
+
*/
|
|
39
|
+
const MAX_SUPPORTED_VERSION = 225;
|
|
34
40
|
const VERSION_GRID_INSTANCING = 216;
|
|
35
41
|
const VERSION_BOOST_UUID = 218;
|
|
36
42
|
const VERSION_SELECTIVE_COMPRESSION = 220;
|
|
37
43
|
const VERSION_NODE_MASK_COMPRESSION = 222;
|
|
38
44
|
const VERSION_BLOSC_COMPRESSION = 223;
|
|
39
45
|
const GRID_TYPE_RE = /^Tree_([A-Za-z0-9]+)_(\d+)_(\d+)_(\d+)$/;
|
|
40
|
-
/**
|
|
46
|
+
/** On-disk value types this parser reads (the `<valueType>` of the grid type), and their layout. */
|
|
41
47
|
const VALUE_FORMATS = {
|
|
42
48
|
float: FLOAT_FORMAT,
|
|
43
49
|
vec3s: VEC3S_FORMAT,
|
|
44
50
|
vec3d: VEC3D_FORMAT,
|
|
45
51
|
vec3i: VEC3I_FORMAT,
|
|
46
52
|
ptdataidx32: PTDATAIDX32_FORMAT,
|
|
53
|
+
// K7.C: OpenVDB 13+ `HalfGrid`. Values widen exactly to f32, so it parses as a float grid
|
|
54
|
+
// (`valueType: "float"`, `gridType` keeps `Tree_half_5_4_3`; DIVERGES V70).
|
|
55
|
+
half: HALF_FORMAT,
|
|
56
|
+
};
|
|
57
|
+
/** The parsed grid's `valueType` for each on-disk value type. */
|
|
58
|
+
const PARSED_VALUE_TYPE = {
|
|
59
|
+
float: "float",
|
|
60
|
+
vec3s: "vec3s",
|
|
61
|
+
vec3d: "vec3d",
|
|
62
|
+
vec3i: "vec3i",
|
|
63
|
+
ptdataidx32: "ptdataidx32",
|
|
64
|
+
half: "float",
|
|
47
65
|
};
|
|
48
66
|
function isSupportedValueType(t) {
|
|
49
67
|
return Object.prototype.hasOwnProperty.call(VALUE_FORMATS, t);
|
|
@@ -72,7 +90,17 @@ function readBBoxFromMetadata(metadata) {
|
|
|
72
90
|
}
|
|
73
91
|
return null;
|
|
74
92
|
}
|
|
75
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Parses an OpenVDB `.vdb` file (float, half, vec3 and point data grids) into trees you can read, iterate or
|
|
95
|
+
* convert to NanoVDB. Returns the decoded `grids` and a `descriptors` entry for every grid in the file.
|
|
96
|
+
* Throws `VdbFormatError` for a malformed buffer, `VDBUnsupportedError` for unsupported constructs (without
|
|
97
|
+
* `select`; with it, an unsupported grid is reported in its descriptor). See {@link ParseVdbOptions.select} to list
|
|
98
|
+
* grids cheaply or decode only some of them.
|
|
99
|
+
*
|
|
100
|
+
* @param buffer The file's bytes.
|
|
101
|
+
* @param options `select`: which grids to decode.
|
|
102
|
+
*/
|
|
103
|
+
export function parseVdb(buffer, options = {}) {
|
|
76
104
|
const reader = new ByteReader(buffer);
|
|
77
105
|
if (reader.length < 8) {
|
|
78
106
|
throw new VdbFormatError("buffer too short to contain the magic number");
|
|
@@ -87,7 +115,9 @@ export function parseVdb(buffer) {
|
|
|
87
115
|
throw new VDBUnsupportedError(`file version ${fileVersion} is older than the minimum supported version ${MIN_SUPPORTED_VERSION}`);
|
|
88
116
|
}
|
|
89
117
|
if (fileVersion > MAX_SUPPORTED_VERSION) {
|
|
90
|
-
throw new VDBUnsupportedError(`file version ${fileVersion} is newer than the maximum supported version ${MAX_SUPPORTED_VERSION}`
|
|
118
|
+
throw new VDBUnsupportedError(`file version ${fileVersion} is newer than the maximum supported version ${MAX_SUPPORTED_VERSION} ` +
|
|
119
|
+
`(the file was written by a newer OpenVDB; OpenVDB v14 still writes ${MAX_SUPPORTED_VERSION}). ` +
|
|
120
|
+
`Re-save it with OpenVDB 14 or earlier.`);
|
|
91
121
|
}
|
|
92
122
|
reader.u32(); // library version major (informational only)
|
|
93
123
|
reader.u32(); // library version minor (informational only)
|
|
@@ -103,6 +133,9 @@ export function parseVdb(buffer) {
|
|
|
103
133
|
readMetadataMap(reader); // file-level metadata (informational only)
|
|
104
134
|
const gridCount = reader.u32();
|
|
105
135
|
const grids = [];
|
|
136
|
+
const descriptors = [];
|
|
137
|
+
const select = options.select;
|
|
138
|
+
const strict = !select;
|
|
106
139
|
for (let i = 0; i < gridCount; i++) {
|
|
107
140
|
const uniqueName = reader.string();
|
|
108
141
|
const name = uniqueName.split("\x1e")[0] ?? uniqueName;
|
|
@@ -116,7 +149,8 @@ export function parseVdb(buffer) {
|
|
|
116
149
|
if (fileVersion >= VERSION_GRID_INSTANCING) {
|
|
117
150
|
instanceParentName = reader.string();
|
|
118
151
|
}
|
|
119
|
-
|
|
152
|
+
const instanced = instanceParentName !== "";
|
|
153
|
+
if (instanced && strict) {
|
|
120
154
|
throw new VDBUnsupportedError(`grid "${name}": instanced grids (sharing another grid's tree) are not supported`);
|
|
121
155
|
}
|
|
122
156
|
const gridPos = reader.u64AsNumber();
|
|
@@ -129,43 +163,79 @@ export function parseVdb(buffer) {
|
|
|
129
163
|
: headerCompression;
|
|
130
164
|
const metadata = readMetadataMap(reader);
|
|
131
165
|
const useHalf = savedAsHalfFloat || metadata["is_saved_as_half_float"] === true;
|
|
166
|
+
const indexBBox = readBBoxFromMetadata(metadata);
|
|
167
|
+
const gridClass = typeof metadata["class"] === "string" ? metadata["class"] : "";
|
|
168
|
+
// Why this grid cannot be decoded, or null. Strict mode (no `select`) throws it; report mode records it.
|
|
169
|
+
let unsupported = null;
|
|
170
|
+
let valueType = "";
|
|
132
171
|
const match = GRID_TYPE_RE.exec(gridType);
|
|
133
|
-
if (
|
|
134
|
-
|
|
172
|
+
if (instanced) {
|
|
173
|
+
unsupported = "instanced grids (sharing another grid's tree) are not supported";
|
|
174
|
+
}
|
|
175
|
+
else if (!match) {
|
|
176
|
+
unsupported = `unrecognized grid type "${gridType}" (expected "Tree_<valueType>_<log2dim>_<log2dim>_<log2dim>")`;
|
|
135
177
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
178
|
+
else {
|
|
179
|
+
const [, vt, d0, d1, d2] = match;
|
|
180
|
+
valueType = vt;
|
|
181
|
+
if (!isSupportedValueType(valueType)) {
|
|
182
|
+
unsupported = `value type "${valueType}" is not supported (supported: ${Object.keys(VALUE_FORMATS).join(", ")})`;
|
|
183
|
+
}
|
|
184
|
+
else if (d0 !== "5" || d1 !== "4" || d2 !== "3") {
|
|
185
|
+
unsupported = `tree configuration ${d0}-${d1}-${d2} is not supported (only the 5-4-3 tree is in scope)`;
|
|
186
|
+
}
|
|
140
187
|
}
|
|
141
|
-
if (
|
|
142
|
-
throw new VDBUnsupportedError(`grid "${name}":
|
|
188
|
+
if (unsupported !== null && strict)
|
|
189
|
+
throw new VDBUnsupportedError(`grid "${name}": ${unsupported}`);
|
|
190
|
+
let transform = null;
|
|
191
|
+
if (unsupported === null) {
|
|
192
|
+
try {
|
|
193
|
+
transform = readTransform(reader);
|
|
194
|
+
}
|
|
195
|
+
catch (e) {
|
|
196
|
+
if (strict || !(e instanceof VDBUnsupportedError))
|
|
197
|
+
throw e;
|
|
198
|
+
unsupported = `transform: ${e.message}`;
|
|
199
|
+
}
|
|
143
200
|
}
|
|
144
|
-
const
|
|
145
|
-
const { background, leaves, tiles, activeVoxelCount, pointLeaves, pointOutputBudget } = readTree(reader, {
|
|
146
|
-
fileVersion,
|
|
147
|
-
compression,
|
|
148
|
-
useHalf,
|
|
149
|
-
format: VALUE_FORMATS[valueType],
|
|
150
|
-
pointData: valueType === "ptdataidx32",
|
|
151
|
-
});
|
|
152
|
-
grids.push(createVdbGrid({
|
|
201
|
+
const descriptor = {
|
|
153
202
|
name,
|
|
154
203
|
gridType,
|
|
155
204
|
valueType,
|
|
205
|
+
gridClass,
|
|
156
206
|
transform,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
207
|
+
indexBBox,
|
|
208
|
+
compression: { zip: compression.zip, activeMask: compression.activeMask, blosc: compression.blosc },
|
|
209
|
+
unsupported,
|
|
210
|
+
};
|
|
211
|
+
descriptors.push(descriptor);
|
|
212
|
+
if (unsupported === null && transform !== null && (select === undefined || select(descriptor))) {
|
|
213
|
+
const vt = valueType;
|
|
214
|
+
const { background, leaves, tiles, activeVoxelCount, pointLeaves, pointOutputBudget } = readTree(reader, {
|
|
215
|
+
fileVersion,
|
|
216
|
+
compression,
|
|
217
|
+
useHalf,
|
|
218
|
+
format: VALUE_FORMATS[vt],
|
|
219
|
+
pointData: vt === "ptdataidx32",
|
|
220
|
+
});
|
|
221
|
+
grids.push(createVdbGrid({
|
|
222
|
+
name,
|
|
223
|
+
gridType,
|
|
224
|
+
valueType: PARSED_VALUE_TYPE[vt],
|
|
225
|
+
transform,
|
|
226
|
+
metadata,
|
|
227
|
+
indexBBox,
|
|
228
|
+
activeVoxelCount,
|
|
229
|
+
background,
|
|
230
|
+
leaves,
|
|
231
|
+
tiles,
|
|
232
|
+
...(pointLeaves ? { pointLeaves, pointOutputBudget } : {}),
|
|
233
|
+
}));
|
|
234
|
+
}
|
|
165
235
|
// Defensive re-sync (matches the `mjurczyk/openvdb` reader's own hack):
|
|
166
236
|
// land exactly on the next grid descriptor regardless of any drift.
|
|
167
237
|
reader.seek(endPos);
|
|
168
238
|
}
|
|
169
|
-
return { fileVersion, grids };
|
|
239
|
+
return { fileVersion, grids, descriptors };
|
|
170
240
|
}
|
|
171
241
|
//# sourceMappingURL=parse.js.map
|