@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
|
@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AAO,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/wvdb/wvdbKernel.js (toByte, toTexels, writeBricks, background fill),\n// src/three-openvdb/wvdb/WVDBReader.js (getBackgroundTexel, getScale, baked density stats),\n// src/three-openvdb/wvdb/WVDBLoader.js (attach / updateTextures stats rules),\n// src/three-openvdb/frame/core/FrameVolume.js (getDensityStats, getMeanDensity, getDensityScale),\n// src/three-openvdb/frame/webgpu/frameMipmaps.js (box mip atlas: downsample, packAtlas),\n// src/three-openvdb/frame/webgpu/frameShaderChunks.js (sampleMipAtlas, sampleMipmapped, getLod).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript, works from our decoded `.wvdb` levels (read.ts) instead of his worker kernel;\n// Gaussian mips not ported. Divergences: DIVERGES.md V23–V25.\n\n/**\n * The dense `.wvdb` volume source, CPU half (K3.0, R1 §4.2): the exact bytes\n * mjurczyk's renderer uploads for a `.wvdb` grid, built from our decoded LODs.\n *\n * His path is `WVDBLoader` → `WVDBReader` → worker `wvdbKernel` (8-bit texels:\n * `clamp(value / scale, 0, 1) * 255 | 0`, level sets 255 inside the band, vector\n * grids RGBA8 with alpha 255) → `new FrameVolume(grid.data, { dimensions, bbox })`\n * (an R8 `Data3DTexture`, linear filter, clamp to edge, no GPU mipmaps) plus a CPU\n * box mip atlas (`frameMipmaps.js`: levels 1..n side by side on x). The engine-free\n * GPU upload is `vdbDenseSource` in core; the three textures are `vdbDenseTextures`\n * in `./three`. Both upload exactly these bytes (`test/tools/wvdb-dense.test.ts`\n * checks them against a re-implementation of his upload path).\n *\n * Values are 8-bit and clamped to [0, 1] (R1 §4.3 `normalize: 'clamp01'`): a\n * density above `scale` saturates, as in his renderer.\n */\n\nimport { VDBToolsError } from \"../errors.js\";\nimport type { WvdbBox, WvdbVec3 } from \"./format.js\";\nimport type { WvdbFile, WvdbVolumeGrid, WvdbVolumeLevel } from \"./read.js\";\n\n/** One uploaded 3D texture: texels x fastest, then y, then z. */\nexport interface WvdbDenseTexture {\n /** 1 byte per texel (`r8unorm`) or 4 (`rgba8unorm`). */\n readonly data: Uint8Array<ArrayBuffer>;\n readonly dimensions: WvdbVec3;\n readonly format: \"r8unorm\" | \"rgba8unorm\";\n /** Bytes per texel (1 or 4). */\n readonly texelBytes: 1 | 4;\n /** CPU box mip atlas (levels 1..`levels` side by side on x), or null without mipmaps. */\n readonly mip: WvdbMipAtlas | null;\n}\n\n/** His `packAtlas` output (frameMipmaps.js L65–88). */\nexport interface WvdbMipAtlas {\n readonly data: Uint8Array<ArrayBuffer>;\n readonly dimensions: WvdbVec3;\n /** Levels in the atlas (level 0 is the texture itself). */\n readonly levels: number;\n}\n\n/** Density statistics as his `getDensityStats` (FrameVolume.js L50–62): sum of non-zero texels / 255, and their count. */\nexport interface WvdbTexelStats {\n readonly sum: number;\n readonly count: number;\n}\n\n/** A `.wvdb` LOD as the dense textures his renderer uploads (R1 §4.2 `vdbDenseSource` input). */\nexport interface WvdbDenseVolume {\n readonly kind: \"dense\";\n /** The only dense normalization: 8-bit, `clamp(value / scale, 0, 1)` (R1 §4.3). */\n readonly normalize: \"clamp01\";\n readonly lod: number;\n /** Texels of the density texture; aux textures have the same size. */\n readonly dimensions: WvdbVec3;\n /** World box of the density grid (`grid.bbox`), or null for an empty grid. */\n readonly bbox: WvdbBox | null;\n readonly density: WvdbDenseTexture;\n readonly mask: WvdbDenseTexture | null;\n readonly albedo: WvdbDenseTexture | null;\n readonly emission: WvdbDenseTexture | null;\n /** The stats his volume ends up with: baked (header) when present and the scale is 1, else from the texels. */\n readonly densityStats: WvdbTexelStats;\n readonly densityStatsSource: \"baked\" | \"texels\";\n /** `getMeanDensity` of the one volume: `sum / count`, 0 when empty. */\n readonly meanDensity: number;\n /** Largest density texel / 255. */\n readonly maxDensity: number;\n /** Non-zero density texels. */\n readonly activeTexels: number;\n readonly gridNames: { readonly density: string; readonly mask?: string; readonly albedo?: string; readonly emission?: string };\n}\n\nexport interface WvdbDenseOptions {\n /** Density grid. Default: the grid named `density`, else the first volume grid (his frame.js L519). */\n density?: string;\n /** Scalar grid read as a mask (multiplies density). */\n mask?: string;\n /** Vector grid read as base colour (RGBA8). */\n albedo?: string;\n /** Scalar grid read as emission (`value / scale`; use `scales` for his `emissiveScale`). */\n emission?: string;\n /** LOD to build. Default: the finest LOD the file has decoded. */\n lod?: number;\n /** His `WVDBLoader.setGridScales`: `{ gridName: scale }`, scalar values divide by it (default 1). */\n scales?: Readonly<Record<string, number>>;\n /** Build the CPU box mip atlas (his `FrameVolume` `mipmaps`, default true). */\n mipmaps?: boolean;\n}\n\n/** WVDBReader.js L128 / wvdbKernel.js L20: `(Math.min(Math.max(value, 0.0), 1.0) * 255.0) | 0`. */\nexport const wvdbToByte = (value: number): number => (Math.min(Math.max(value, 0.0), 1.0) * 255.0) | 0;\n\n/**\n * The 8-bit texels his worker kernel produces for one decoded LOD (wvdbKernel.js\n * `toTexels` L24–58, `writeBricks` L89–119 over a background fill L255–256 with\n * `getBackgroundTexel` WVDBReader.js L131–137). Our decoded level already holds\n * the background where no brick is stored, so the per-voxel rule is applied to\n * the whole dense array. Scalar: 1 byte; vector: RGBA8 with alpha 255 (no scale).\n */\nexport function wvdbTexels(grid: WvdbVolumeGrid, level: WvdbVolumeLevel, scale = 1): Uint8Array<ArrayBuffer> {\n const [w, h, d] = level.dimensions;\n const plane = w * h * d;\n const values = level.values;\n if (level.channels === 3) {\n const out = new Uint8Array(plane * 4);\n for (let i = 0; i < plane; i++) {\n out[i * 4] = wvdbToByte(values[i]!);\n out[i * 4 + 1] = wvdbToByte(values[plane + i]!);\n out[i * 4 + 2] = wvdbToByte(values[2 * plane + i]!);\n out[i * 4 + 3] = 255;\n }\n return out;\n }\n const out = new Uint8Array(plane);\n if (grid.class === \"level set\") {\n const background = grid.background[0]!;\n for (let i = 0; i < plane; i++) out[i] = Math.abs(values[i]!) < background ? 255 : 0;\n return out;\n }\n for (let i = 0; i < plane; i++) out[i] = wvdbToByte(values[i]! / scale);\n return out;\n}\n\n/** FrameVolume.js L50–62 `getDensityStats`. */\nexport function wvdbTexelStats(data: Uint8Array): WvdbTexelStats {\n let sum = 0;\n let count = 0;\n for (let i = 0; i < data.length; i++) {\n if (data[i]! > 0) {\n sum += data[i]!;\n count++;\n }\n }\n return { sum: sum / 255.0, count };\n}\n\n/** frameMipmaps.js L14 `getLevelSize` (ceil sizes; the WebGL path floors, R1 §8 quality note 5). */\nexport const wvdbMipLevelSize = (size: number, level: number): number => Math.max(1, Math.ceil(size / 2 ** level));\n\n/** frameMipmaps.js L16–17 `getMipLevelCount`. */\nexport const wvdbMipLevelCount = (width: number, height: number, depth: number): number =>\n Math.ceil(Math.log2(Math.max(width, height, depth, 1)));\n\n/** frameMipmaps.js L20–62: 2x2x2 box mean, `Math.round(sum / 8)`, edge taps clamped. */\nfunction downsample(source: Uint8Array<ArrayBuffer>, width: number, height: number, depth: number, channels: number) {\n const tw = wvdbMipLevelSize(width, 1);\n const th = wvdbMipLevelSize(height, 1);\n const td = wvdbMipLevelSize(depth, 1);\n const target = new Uint8Array(tw * th * td * channels);\n for (let z = 0; z < td; z++) {\n const z0 = Math.min(z * 2, depth - 1);\n const z1 = Math.min(z * 2 + 1, depth - 1);\n for (let y = 0; y < th; y++) {\n const y0 = Math.min(y * 2, height - 1);\n const y1 = Math.min(y * 2 + 1, height - 1);\n const row00 = (y0 + z0 * height) * width;\n const row10 = (y1 + z0 * height) * width;\n const row01 = (y0 + z1 * height) * width;\n const row11 = (y1 + z1 * height) * width;\n for (let x = 0; x < tw; x++) {\n const x0 = Math.min(x * 2, width - 1);\n const x1 = Math.min(x * 2 + 1, width - 1);\n const t = (x + (y + z * th) * tw) * channels;\n for (let c = 0; c < channels; c++) {\n const sum =\n source[(x0 + row00) * channels + c]! +\n source[(x1 + row00) * channels + c]! +\n source[(x0 + row10) * channels + c]! +\n source[(x1 + row10) * channels + c]! +\n source[(x0 + row01) * channels + c]! +\n source[(x1 + row01) * channels + c]! +\n source[(x0 + row11) * channels + c]! +\n source[(x1 + row11) * channels + c]!;\n target[t + c] = Math.round(sum / 8);\n }\n }\n }\n }\n return { data: target, width: tw, height: th, depth: td };\n}\n\n/**\n * frameMipmaps.js L90–106 `buildAtlas` + L65–88 `packAtlas`: levels 1..n (n =\n * `ceil(log2(max side))`), level l at x = atlasWidth − atlasWidth / 2^(l−1);\n * atlas width 2^max(ceil(log2 width), n), height and depth those of level 1.\n * Null when the texture has one texel on every side.\n */\nexport function wvdbMipAtlas(data: Uint8Array<ArrayBuffer>, dimensions: readonly number[], channels: 1 | 4): WvdbMipAtlas | null {\n const [width, height, depth] = dimensions as WvdbVec3;\n const count = wvdbMipLevelCount(width, height, depth);\n if (count < 1) return null;\n const levels: ReturnType<typeof downsample>[] = [];\n let level = { data, width, height, depth };\n for (let index = 1; index <= count; index++) {\n level = downsample(level.data, level.width, level.height, level.depth, channels);\n levels.push(level);\n }\n const atlasWidth = 2 ** Math.max(Math.ceil(Math.log2(width)), levels.length);\n const atlasHeight = wvdbMipLevelSize(height, 1);\n const atlasDepth = wvdbMipLevelSize(depth, 1);\n const atlas = new Uint8Array(atlasWidth * atlasHeight * atlasDepth * channels);\n levels.forEach((l, levelIndex) => {\n const offset = atlasWidth - atlasWidth / 2 ** levelIndex;\n for (let z = 0; z < l.depth; z++) {\n for (let y = 0; y < l.height; y++) {\n const sourceStart = (y + z * l.height) * l.width * channels;\n const targetStart = (offset + (y + z * atlasHeight) * atlasWidth) * channels;\n atlas.set(l.data.subarray(sourceStart, sourceStart + l.width * channels), targetStart);\n }\n }\n });\n return { data: atlas, dimensions: [atlasWidth, atlasHeight, atlasDepth], levels: levels.length };\n}\n\nfunction denseTexture(data: Uint8Array<ArrayBuffer>, dimensions: WvdbVec3, texelBytes: 1 | 4, mipmaps: boolean): WvdbDenseTexture {\n return {\n data,\n dimensions,\n format: texelBytes === 4 ? \"rgba8unorm\" : \"r8unorm\",\n texelBytes,\n mip: mipmaps ? wvdbMipAtlas(data, dimensions, texelBytes) : null,\n };\n}\n\nfunction volumeGrid(file: WvdbFile, name: string, role: string): WvdbVolumeGrid {\n const grid = file.grids.find((g) => g.name === name);\n if (!grid) throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbDenseVolume: no grid named \"${name}\" for ${role} (grids: ${file.grids.map((g) => g.name).join(\", \")})`);\n if (grid.kind !== \"volume\") throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbDenseVolume: grid \"${name}\" (${role}) is a points grid; dense sources take volume grids`);\n return grid;\n}\n\nfunction levelOf(grid: WvdbVolumeGrid, lod: number): WvdbVolumeLevel {\n const level = grid.levels[lod];\n if (!level) {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbDenseVolume: LOD ${lod} of \"${grid.name}\" is not decoded (${grid.levels.length} decoded); read the file with a larger maxLod`);\n }\n return level;\n}\n\n/**\n * Builds the dense textures his renderer would upload for one LOD of a decoded\n * `.wvdb` file: density (R8), optional mask (R8), albedo (RGBA8) and emission\n * (R8), each with its CPU box mip atlas, plus the density stats his volume uses\n * for `normalizeDensity` (`meanDensity`).\n */\nexport function wvdbDenseVolume(file: WvdbFile, o: WvdbDenseOptions = {}): WvdbDenseVolume {\n const volumeGrids = file.grids.filter((g): g is WvdbVolumeGrid => g.kind === \"volume\");\n const densityName = o.density ?? (file.grids.find((g) => g.name === \"density\" && g.kind === \"volume\") ?? volumeGrids[0])?.name;\n if (densityName === undefined) throw new VDBToolsError(\"VDB_BAD_OPTION\", \"wvdbDenseVolume: the file has no volume grid\");\n const density = volumeGrid(file, densityName, \"density\");\n if (density.channels !== 1) throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbDenseVolume: density grid \"${densityName}\" has 3 channels; pass a scalar grid`);\n const lod = o.lod ?? density.levels.length - 1;\n if (!Number.isInteger(lod) || lod < 0) throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbDenseVolume: lod must be a non-negative integer, got ${o.lod}`);\n const mipmaps = o.mipmaps ?? true;\n // WVDBReader.js L494: scales[name] || 1.0\n const scaleOf = (name: string) => o.scales?.[name] || 1.0;\n const level = levelOf(density, lod);\n const dimensions = [...level.dimensions] as WvdbVec3;\n const densityData = wvdbTexels(density, level, scaleOf(densityName));\n\n const aux = (name: string | undefined, role: \"mask\" | \"albedo\" | \"emission\"): WvdbDenseTexture | null => {\n if (name === undefined) return null;\n const grid = volumeGrid(file, name, role);\n const want = role === \"albedo\" ? 3 : 1;\n if (grid.channels !== want) throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbDenseVolume: ${role} grid \"${name}\" has ${grid.channels} channel(s), expected ${want}`);\n const auxLevel = levelOf(grid, lod);\n if (auxLevel.dimensions.some((v, a) => v !== dimensions[a])) {\n // FrameVolume.js L357–405: raw aux grids are uploaded at the density grid's dimensions.\n throw new VDBToolsError(\"VDB_BAD_OPTION\", \n `wvdbDenseVolume: ${role} grid \"${name}\" LOD ${lod} is ${auxLevel.dimensions.join(\"x\")}, density is ${dimensions.join(\"x\")}; ` +\n \"his renderer uploads aux grids at the density size, so they must match\",\n );\n }\n const data = wvdbTexels(grid, auxLevel, scaleOf(name));\n return denseTexture(data, dimensions, role === \"albedo\" ? 4 : 1, mipmaps);\n };\n\n // WVDBReader.js L519–523 + WVDBLoader.js L147–152: baked stats when the header has\n // meanDensity and the scale is 1; else WVDBLoader.js L196–198 getDensityStats(data).\n const baked = typeof density.meanDensity === \"number\" && scaleOf(densityName) === 1.0;\n const densityStats: WvdbTexelStats = baked\n ? { sum: density.meanDensity! * density.nonZeroVoxels!, count: density.nonZeroVoxels! }\n : wvdbTexelStats(densityData);\n let max = 0;\n let active = 0;\n for (let i = 0; i < densityData.length; i++) {\n const v = densityData[i]!;\n if (v > max) max = v;\n if (v > 0) active++;\n }\n\n return {\n kind: \"dense\",\n normalize: \"clamp01\",\n lod,\n dimensions,\n bbox: density.bbox,\n density: denseTexture(densityData, dimensions, 1, mipmaps),\n mask: aux(o.mask, \"mask\"),\n albedo: aux(o.albedo, \"albedo\"),\n emission: aux(o.emission, \"emission\"),\n densityStats,\n densityStatsSource: baked ? \"baked\" : \"texels\",\n // FrameVolume.js L65–75 getMeanDensity (one volume)\n meanDensity: densityStats.count > 0 ? densityStats.sum / densityStats.count : 0.0,\n maxDensity: max / 255,\n activeTexels: active,\n gridNames: {\n density: densityName,\n ...(o.mask !== undefined ? { mask: o.mask } : {}),\n ...(o.albedo !== undefined ? { albedo: o.albedo } : {}),\n ...(o.emission !== undefined ? { emission: o.emission } : {}),\n },\n };\n}\n\n/** FrameVolume.js L561–568 `getDensityScale`: `densityScale / meanDensity` with `normalizeDensity`. */\nexport function wvdbDensityScale(volume: Pick<WvdbDenseVolume, \"meanDensity\">, densityScale = 1.0, normalizeDensity = true): number {\n return normalizeDensity && volume.meanDensity > 0.0 ? densityScale / volume.meanDensity : densityScale;\n}\n\n// ---------------------------------------------------------------------------\n// CPU twin of the dense source's sampling (vdbSrcDensity & co. in core)\n// ---------------------------------------------------------------------------\n\n/** Linear filtering, clamp to edge, of one channel at uvw in [0, 1]³ (texel centres at (i + 0.5) / size). */\nfunction linear(data: Uint8Array, dims: readonly number[], texelBytes: number, channel: number, u: number, v: number, w: number): number {\n // dims: the sampled texture's size (for the mip atlas, the whole atlas: its taps clamp at the atlas edge, not the level's).\n const [W, H, D] = dims as WvdbVec3;\n const fx = u * W - 0.5;\n const fy = v * H - 0.5;\n const fz = w * D - 0.5;\n const x0 = Math.floor(fx);\n const y0 = Math.floor(fy);\n const z0 = Math.floor(fz);\n const tx = fx - x0;\n const ty = fy - y0;\n const tz = fz - z0;\n const cl = (i: number, n: number) => Math.min(Math.max(i, 0), n - 1);\n const at = (x: number, y: number, z: number) => data[(cl(x, W) + (cl(y, H) + cl(z, D) * H) * W) * texelBytes + channel]! / 255;\n const c00 = at(x0, y0, z0) * (1 - tx) + at(x0 + 1, y0, z0) * tx;\n const c10 = at(x0, y0 + 1, z0) * (1 - tx) + at(x0 + 1, y0 + 1, z0) * tx;\n const c01 = at(x0, y0, z0 + 1) * (1 - tx) + at(x0 + 1, y0, z0 + 1) * tx;\n const c11 = at(x0, y0 + 1, z0 + 1) * (1 - tx) + at(x0 + 1, y0 + 1, z0 + 1) * tx;\n const c0 = c00 * (1 - ty) + c10 * ty;\n const c1 = c01 * (1 - ty) + c11 * ty;\n return c0 * (1 - tz) + c1 * tz;\n}\n\n/** frameShaderChunks.js L838–846 `sampleMipAtlas` (level ≥ 1). */\nfunction sampleMipAtlasCpu(tex: WvdbDenseTexture, level: number, uvw: readonly number[], channel: number): number {\n const atlas = tex.mip!;\n const [AW, AH, AD] = atlas.dimensions;\n const size = tex.dimensions.map((t) => Math.max(1, Math.ceil(t / 2 ** level)));\n const offset = AW - AW / 2 ** (level - 1);\n const texel = uvw.map((c, a) => Math.min(Math.max(c * size[a]!, 0.5), size[a]! - 0.5));\n return linear(atlas.data, [AW, AH, AD], tex.texelBytes, channel, (texel[0]! + offset) / AW, texel[1]! / AH, texel[2]! / AD);\n}\n\n/**\n * CPU twin of the dense source's read at `uvw` (already offset and wrapped) and\n * `lod` (frameShaderChunks.js L849–877 `sampleMipmapped` / `sample3D`): hardware\n * trilinear on the 8-bit texels (as normalized floats), and with mip levels a\n * linear blend of the two nearest levels from the atlas. Real GPUs filter with\n * limited weight precision (typically 8 fractional bits), so compare with a\n * tolerance of about 1/255 of the local value range.\n */\nexport function sampleWvdbDenseTexture(tex: WvdbDenseTexture, uvw: readonly number[], lod = 0, channel = 0): number {\n const levels = tex.mip?.levels ?? 0;\n const base = () => linear(tex.data, tex.dimensions, tex.texelBytes, channel, uvw[0]!, uvw[1]!, uvw[2]!);\n if (levels === 0) return base();\n const level = Math.min(lod, levels);\n if (level <= 0) return base();\n const level0 = Math.floor(level);\n const low = level0 < 0.5 ? base() : sampleMipAtlasCpu(tex, level0, uvw, channel);\n const high = sampleMipAtlasCpu(tex, Math.min(level0 + 1, levels), uvw, channel);\n return low + (high - low) * (level - level0);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dense.js","sourceRoot":"","sources":["../../../src/tools/wvdb/dense.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,2FAA2F;AAC3F,8FAA8F;AAC9F,gFAAgF;AAChF,oGAAoG;AACpG,2FAA2F;AAC3F,mGAAmG;AACnG,4GAA4G;AAC5G,qGAAqG;AACrG,8DAA8D;AAE9D;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAkH7C,mGAAmG;AACnG,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;AAEvG;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,IAAoB,EAAE,KAAsB,EAAE,KAAK,GAAG,CAAC;IAChF,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC;IACnC,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/B,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC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AM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACjF,MAAM,IAAI,GAAG,iBAAiB,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAChF,OAAO,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/wvdb/wvdbKernel.js (toByte, toTexels, writeBricks, background fill),\n// src/three-openvdb/wvdb/WVDBReader.js (getBackgroundTexel, getScale, baked density stats),\n// src/three-openvdb/wvdb/WVDBLoader.js (attach / updateTextures stats rules),\n// src/three-openvdb/frame/core/FrameVolume.js (getDensityStats, getMeanDensity, getDensityScale),\n// src/three-openvdb/frame/webgpu/frameMipmaps.js (box mip atlas: downsample, packAtlas),\n// src/three-openvdb/frame/webgpu/frameShaderChunks.js (sampleMipAtlas, sampleMipmapped, getLod).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript, works from our decoded `.wvdb` levels (read.ts) instead of his worker kernel;\n// Gaussian mips not ported. Divergences: DIVERGES.md V23–V25.\n\n/**\n * The dense `.wvdb` volume source, CPU half (K3.0, R1 §4.2): the exact bytes\n * mjurczyk's renderer uploads for a `.wvdb` grid, built from our decoded LODs.\n *\n * His path is `WVDBLoader` → `WVDBReader` → worker `wvdbKernel` (8-bit texels:\n * `clamp(value / scale, 0, 1) * 255 | 0`, level sets 255 inside the band, vector\n * grids RGBA8 with alpha 255) → `new FrameVolume(grid.data, { dimensions, bbox })`\n * (an R8 `Data3DTexture`, linear filter, clamp to edge, no GPU mipmaps) plus a CPU\n * box mip atlas (`frameMipmaps.js`: levels 1..n side by side on x). The engine-free\n * GPU upload is `vdbDenseSource` in core; the three textures are `vdbDenseTextures`\n * in `./three`. Both upload exactly these bytes (`test/tools/wvdb-dense.test.ts`\n * checks them against a re-implementation of his upload path).\n *\n * Values are 8-bit and clamped to [0, 1] (R1 §4.3 `normalize: 'clamp01'`): a\n * density above `scale` saturates, as in his renderer.\n */\n\nimport { VDBToolsError } from \"../errors.js\";\nimport type { WvdbBox, WvdbVec3 } from \"./format.js\";\nimport type { WvdbFile, WvdbVolumeGrid, WvdbVolumeLevel } from \"./read.js\";\n\n/** One uploaded 3D texture: texels x fastest, then y, then z. */\nexport interface WvdbDenseTexture {\n /** 1 byte per texel (`r8unorm`) or 4 (`rgba8unorm`). */\n readonly data: Uint8Array<ArrayBuffer>;\n /** Texels per axis. */\n readonly dimensions: WvdbVec3;\n /** The WebGPU texture format the bytes are laid out for. */\n readonly format: \"r8unorm\" | \"rgba8unorm\";\n /** Bytes per texel (1 or 4). */\n readonly texelBytes: 1 | 4;\n /** CPU box mip atlas (levels 1..`levels` side by side on x), or null without mipmaps. */\n readonly mip: WvdbMipAtlas | null;\n /**\n * K4.22: a partially streamed LOD's bricks to fill from a coarser LOD (`wvdbDensePartialVolume` with\n * `fill: 'upsample'`), or absent / null. `data` and `mip` then hold the background in those bricks; the core's\n * dense source fills them on the GPU, `wvdbDenseResolve` on the CPU.\n */\n readonly fill?: WvdbDenseFill | null;\n}\n\n/**\n * K4.22: the bricks of a partially streamed LOD that are stored but not decoded yet, and the coarser LOD's texels\n * to fill them with (his `wvdbKernel` upsample: trilinear, texel centres aligned, edges clamped).\n */\nexport interface WvdbDenseFill {\n /** One bit per brick of the texture (brick index x fastest; word `index >> 5`, bit `index & 31`). */\n readonly pending: Uint32Array;\n /** Bricks set in `pending`. */\n readonly count: number;\n /** The coarser LOD's texels in the texture's format (a complete LOD), and their size. */\n readonly from: { readonly data: Uint8Array<ArrayBuffer>; readonly dimensions: WvdbVec3 };\n /**\n * The mip atlas of the filled texture: `'box'` builds every level from the filled texels (his frameMipmaps);\n * `'coarse'` takes level 1 of the pending bricks from the coarser LOD itself (the LOD a `.wvdb` bake makes by a\n * 2x box filter of this one), when its size is level 1's, so a far view of a pending brick is the coarser LOD,\n * not a blur of its upsample. Default `'coarse'`.\n */\n readonly mips?: \"coarse\" | \"box\";\n}\n\n/** His `packAtlas` output (frameMipmaps.js L65–88). */\nexport interface WvdbMipAtlas {\n /** The atlas texels, x fastest. */\n readonly data: Uint8Array<ArrayBuffer>;\n /** Atlas size in texels per axis. */\n readonly dimensions: WvdbVec3;\n /** Levels in the atlas (level 0 is the texture itself). */\n readonly levels: number;\n}\n\n/** Density statistics as his `getDensityStats` (FrameVolume.js L50–62): sum of non-zero texels / 255, and their count. */\nexport interface WvdbTexelStats {\n /** Sum of the non-zero texels, each divided by 255. */\n readonly sum: number;\n /** Number of non-zero texels. */\n readonly count: number;\n}\n\n/** A `.wvdb` LOD as the dense textures his renderer uploads (R1 §4.2 `vdbDenseSource` input). */\nexport interface WvdbDenseVolume {\n /** Discriminant: a dense (texture) volume. */\n readonly kind: \"dense\";\n /** The only dense normalization: 8-bit, `clamp(value / scale, 0, 1)` (R1 §4.3). */\n readonly normalize: \"clamp01\";\n /** The LOD these textures were built from (0 is the coarsest). */\n readonly lod: number;\n /** Texels of the density texture; aux textures have the same size. */\n readonly dimensions: WvdbVec3;\n /** World box of the density grid (`grid.bbox`), or null for an empty grid. */\n readonly bbox: WvdbBox | null;\n /** The density texture (R8). */\n readonly density: WvdbDenseTexture;\n /** The mask texture (R8), or null without a mask grid. */\n readonly mask: WvdbDenseTexture | null;\n /** The albedo texture (RGBA8), or null without an albedo grid. */\n readonly albedo: WvdbDenseTexture | null;\n /** The emission texture (R8), or null without an emission grid. */\n readonly emission: WvdbDenseTexture | null;\n /** The stats his volume ends up with: baked (header) when present and the scale is 1, else from the texels. */\n readonly densityStats: WvdbTexelStats;\n /** Where `densityStats` came from: the file header (`baked`) or the texels. */\n readonly densityStatsSource: \"baked\" | \"texels\";\n /** `getMeanDensity` of the one volume: `sum / count`, 0 when empty. */\n readonly meanDensity: number;\n /** Largest density texel / 255. */\n readonly maxDensity: number;\n /** Non-zero density texels. */\n readonly activeTexels: number;\n /** The names of the `.wvdb` grids each texture was read from. */\n readonly gridNames: { readonly density: string; readonly mask?: string; readonly albedo?: string; readonly emission?: string };\n}\n\n/** Options of {@link wvdbDenseVolume}: which grids fill which channel, the LOD, scales and mipmaps. */\nexport interface WvdbDenseOptions {\n /** Density grid. Default: the grid named `density`, else the first volume grid (his frame.js L519). */\n density?: string;\n /** Scalar grid read as a mask (multiplies density). */\n mask?: string;\n /** Vector grid read as base colour (RGBA8). */\n albedo?: string;\n /** Scalar grid read as emission (`value / scale`; use `scales` for his `emissiveScale`). */\n emission?: string;\n /** LOD to build. Default: the finest LOD the file has decoded. */\n lod?: number;\n /** His `WVDBLoader.setGridScales`: `{ gridName: scale }`, scalar values divide by it (default 1). */\n scales?: Readonly<Record<string, number>>;\n /** Build the CPU box mip atlas (his `FrameVolume` `mipmaps`, default true). */\n mipmaps?: boolean;\n}\n\n/** WVDBReader.js L128 / wvdbKernel.js L20: `(Math.min(Math.max(value, 0.0), 1.0) * 255.0) | 0`. */\nexport const wvdbToByte = (value: number): number => (Math.min(Math.max(value, 0.0), 1.0) * 255.0) | 0;\n\n/**\n * The 8-bit texels his worker kernel produces for one decoded LOD (wvdbKernel.js\n * `toTexels` L24–58, `writeBricks` L89–119 over a background fill L255–256 with\n * `getBackgroundTexel` WVDBReader.js L131–137). Our decoded level already holds\n * the background where no brick is stored, so the per-voxel rule is applied to\n * the whole dense array. Scalar: 1 byte; vector: RGBA8 with alpha 255 (no scale).\n */\nexport function wvdbTexels(grid: WvdbVolumeGrid, level: WvdbVolumeLevel, scale = 1): Uint8Array<ArrayBuffer> {\n const [w, h, d] = level.dimensions;\n const plane = w * h * d;\n const values = level.values;\n if (level.channels === 3) {\n const out = new Uint8Array(plane * 4);\n for (let i = 0; i < plane; i++) {\n out[i * 4] = wvdbToByte(values[i]!);\n out[i * 4 + 1] = wvdbToByte(values[plane + i]!);\n out[i * 4 + 2] = wvdbToByte(values[2 * plane + i]!);\n out[i * 4 + 3] = 255;\n }\n return out;\n }\n const out = new Uint8Array(plane);\n if (grid.class === \"level set\") {\n const background = grid.background[0]!;\n for (let i = 0; i < plane; i++) out[i] = Math.abs(values[i]!) < background ? 255 : 0;\n return out;\n }\n for (let i = 0; i < plane; i++) out[i] = wvdbToByte(values[i]! / scale);\n return out;\n}\n\n/** FrameVolume.js L50–62 `getDensityStats`. */\nexport function wvdbTexelStats(data: Uint8Array): WvdbTexelStats {\n let sum = 0;\n let count = 0;\n for (let i = 0; i < data.length; i++) {\n if (data[i]! > 0) {\n sum += data[i]!;\n count++;\n }\n }\n return { sum: sum / 255.0, count };\n}\n\n/** frameMipmaps.js L14 `getLevelSize` (ceil sizes; the WebGL path floors, R1 §8 quality note 5). */\nexport const wvdbMipLevelSize = (size: number, level: number): number => Math.max(1, Math.ceil(size / 2 ** level));\n\n/** frameMipmaps.js L16–17 `getMipLevelCount`. */\nexport const wvdbMipLevelCount = (width: number, height: number, depth: number): number =>\n Math.ceil(Math.log2(Math.max(width, height, depth, 1)));\n\n/** frameMipmaps.js L20–62: 2x2x2 box mean, `Math.round(sum / 8)`, edge taps clamped. */\nfunction downsample(source: Uint8Array<ArrayBuffer>, width: number, height: number, depth: number, channels: number) {\n const tw = wvdbMipLevelSize(width, 1);\n const th = wvdbMipLevelSize(height, 1);\n const td = wvdbMipLevelSize(depth, 1);\n const target = new Uint8Array(tw * th * td * channels);\n for (let z = 0; z < td; z++) {\n const z0 = Math.min(z * 2, depth - 1);\n const z1 = Math.min(z * 2 + 1, depth - 1);\n for (let y = 0; y < th; y++) {\n const y0 = Math.min(y * 2, height - 1);\n const y1 = Math.min(y * 2 + 1, height - 1);\n const row00 = (y0 + z0 * height) * width;\n const row10 = (y1 + z0 * height) * width;\n const row01 = (y0 + z1 * height) * width;\n const row11 = (y1 + z1 * height) * width;\n for (let x = 0; x < tw; x++) {\n const x0 = Math.min(x * 2, width - 1);\n const x1 = Math.min(x * 2 + 1, width - 1);\n const t = (x + (y + z * th) * tw) * channels;\n for (let c = 0; c < channels; c++) {\n const sum =\n source[(x0 + row00) * channels + c]! +\n source[(x1 + row00) * channels + c]! +\n source[(x0 + row10) * channels + c]! +\n source[(x1 + row10) * channels + c]! +\n source[(x0 + row01) * channels + c]! +\n source[(x1 + row01) * channels + c]! +\n source[(x0 + row11) * channels + c]! +\n source[(x1 + row11) * channels + c]!;\n target[t + c] = Math.round(sum / 8);\n }\n }\n }\n }\n return { data: target, width: tw, height: th, depth: td };\n}\n\n/**\n * The mip atlas size and level count `wvdbMipAtlas` gives for a texture of `dimensions`, without building it\n * (null when the texture has one texel on every side).\n */\nexport function wvdbMipAtlasLayout(dimensions: readonly number[]): { dimensions: WvdbVec3; levels: number } | null {\n const [width, height, depth] = dimensions as WvdbVec3;\n const levels = wvdbMipLevelCount(width, height, depth);\n if (levels < 1) return null;\n return { dimensions: [2 ** Math.max(Math.ceil(Math.log2(width)), levels), wvdbMipLevelSize(height, 1), wvdbMipLevelSize(depth, 1)], levels };\n}\n\n/**\n * frameMipmaps.js L90–106 `buildAtlas` + L65–88 `packAtlas`: levels 1..n (n =\n * `ceil(log2(max side))`), level l at x = atlasWidth − atlasWidth / 2^(l−1);\n * atlas width 2^max(ceil(log2 width), n), height and depth those of level 1.\n * Null when the texture has one texel on every side.\n */\nexport function wvdbMipAtlas(\n data: Uint8Array<ArrayBuffer>,\n dimensions: readonly number[],\n channels: 1 | 4,\n /** K4.22: edits level 1 (texels x fastest) before the higher levels are built from it. */\n editLevel1?: (level: { data: Uint8Array<ArrayBuffer>; width: number; height: number; depth: number }) => void,\n): WvdbMipAtlas | null {\n const [width, height, depth] = dimensions as WvdbVec3;\n const count = wvdbMipLevelCount(width, height, depth);\n if (count < 1) return null;\n const levels: ReturnType<typeof downsample>[] = [];\n let level = { data, width, height, depth };\n for (let index = 1; index <= count; index++) {\n level = downsample(level.data, level.width, level.height, level.depth, channels);\n if (index === 1) editLevel1?.(level);\n levels.push(level);\n }\n const atlasWidth = 2 ** Math.max(Math.ceil(Math.log2(width)), levels.length);\n const atlasHeight = wvdbMipLevelSize(height, 1);\n const atlasDepth = wvdbMipLevelSize(depth, 1);\n const atlas = new Uint8Array(atlasWidth * atlasHeight * atlasDepth * channels);\n levels.forEach((l, levelIndex) => {\n const offset = atlasWidth - atlasWidth / 2 ** levelIndex;\n for (let z = 0; z < l.depth; z++) {\n for (let y = 0; y < l.height; y++) {\n const sourceStart = (y + z * l.height) * l.width * channels;\n const targetStart = (offset + (y + z * atlasHeight) * atlasWidth) * channels;\n atlas.set(l.data.subarray(sourceStart, sourceStart + l.width * channels), targetStart);\n }\n }\n });\n return { data: atlas, dimensions: [atlasWidth, atlasHeight, atlasDepth], levels: levels.length };\n}\n\nfunction denseTexture(data: Uint8Array<ArrayBuffer>, dimensions: WvdbVec3, texelBytes: 1 | 4, mipmaps: boolean): WvdbDenseTexture {\n return {\n data,\n dimensions,\n format: texelBytes === 4 ? \"rgba8unorm\" : \"r8unorm\",\n texelBytes,\n mip: mipmaps ? wvdbMipAtlas(data, dimensions, texelBytes) : null,\n };\n}\n\n/**\n * K4.22: a texture whose `fill` bricks are still background. Its mip atlas is built on first read of `mip.data`\n * (from the background-filled texels): the core's dense source builds the filled atlas on the GPU and never reads it.\n */\nexport function wvdbDenseFillTexture(data: Uint8Array<ArrayBuffer>, dimensions: WvdbVec3, texelBytes: 1 | 4, mipmaps: boolean, fill: WvdbDenseFill | null): WvdbDenseTexture {\n if (!fill) return denseTexture(data, dimensions, texelBytes, mipmaps);\n const layout = mipmaps ? wvdbMipAtlasLayout(dimensions) : null;\n let atlas: Uint8Array<ArrayBuffer> | null = null;\n const mip: WvdbMipAtlas | null = layout\n ? {\n get data() {\n return (atlas ??= wvdbMipAtlas(data, dimensions, texelBytes)!.data);\n },\n dimensions: layout.dimensions,\n levels: layout.levels,\n }\n : null;\n return { data, dimensions, format: texelBytes === 4 ? \"rgba8unorm\" : \"r8unorm\", texelBytes, mip, fill };\n}\n\n/** @internal How {@link wvdbDenseAssemble} reads each grid's level and makes its texture (K4.22: partial LODs). */\nexport interface WvdbDenseAssembly {\n /** The level of `grid` to upload. */\n level(grid: WvdbVolumeGrid, role: string): WvdbVolumeLevel;\n /** The texture of `grid` from its texels (default: {@link denseTexture} with a CPU atlas). */\n texture?(grid: WvdbVolumeGrid, level: WvdbVolumeLevel, data: Uint8Array<ArrayBuffer>, texelBytes: 1 | 4, mipmaps: boolean, scale: number): WvdbDenseTexture;\n}\n\nfunction volumeGrid(file: WvdbFile, name: string, role: string): WvdbVolumeGrid {\n const grid = file.grids.find((g) => g.name === name);\n if (!grid) throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbDenseVolume: no grid named \"${name}\" for ${role} (grids: ${file.grids.map((g) => g.name).join(\", \")})`);\n if (grid.kind !== \"volume\") throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbDenseVolume: grid \"${name}\" (${role}) is a points grid; dense sources take volume grids`);\n return grid;\n}\n\nfunction levelOf(grid: WvdbVolumeGrid, lod: number): WvdbVolumeLevel {\n const level = grid.levels[lod];\n if (!level) {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbDenseVolume: LOD ${lod} of \"${grid.name}\" is not decoded (${grid.levels.length} decoded); read the file with a larger maxLod`);\n }\n return level;\n}\n\n/**\n * Builds the dense textures his renderer would upload for one LOD of a decoded\n * `.wvdb` file: density (R8), optional mask (R8), albedo (RGBA8) and emission\n * (R8), each with its CPU box mip atlas, plus the density stats his volume uses\n * for `normalizeDensity` (`meanDensity`).\n * @param file A decoded `.wvdb` ({@link readWvdb}) with the LOD's levels.\n * @param o Which grids to read, the LOD, scales and mipmaps.\n */\nexport function wvdbDenseVolume(file: WvdbFile, o: WvdbDenseOptions = {}): WvdbDenseVolume {\n const density = wvdbDenseDensityGrid(file, o);\n const lod = o.lod ?? density.levels.length - 1;\n if (!Number.isInteger(lod) || lod < 0) throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbDenseVolume: lod must be a non-negative integer, got ${o.lod}`);\n return wvdbDenseAssemble(file, o, lod, { level: (grid) => levelOf(grid, lod) });\n}\n\n/** @internal The density grid {@link wvdbDenseVolume} reads (`o.density`, else `density`, else the first volume grid). */\nexport function wvdbDenseDensityGrid(file: WvdbFile, o: Pick<WvdbDenseOptions, \"density\">): WvdbVolumeGrid {\n const volumeGrids = file.grids.filter((g): g is WvdbVolumeGrid => g.kind === \"volume\");\n const densityName = o.density ?? (file.grids.find((g) => g.name === \"density\" && g.kind === \"volume\") ?? volumeGrids[0])?.name;\n if (densityName === undefined) throw new VDBToolsError(\"VDB_BAD_OPTION\", \"wvdbDenseVolume: the file has no volume grid\");\n const density = volumeGrid(file, densityName, \"density\");\n if (density.channels !== 1) throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbDenseVolume: density grid \"${densityName}\" has 3 channels; pass a scalar grid`);\n return density;\n}\n\n/**\n * @internal {@link wvdbDenseVolume}'s assembly from one level per grid (`how.level`): texels, aux channels, stats.\n * K4.22's partial volumes pass the stream event's levels and textures with a `fill`.\n */\nexport function wvdbDenseAssemble(file: WvdbFile, o: WvdbDenseOptions, lod: number, how: WvdbDenseAssembly): WvdbDenseVolume {\n const density = wvdbDenseDensityGrid(file, o);\n const densityName = density.name;\n const mipmaps = o.mipmaps ?? true;\n // WVDBReader.js L494: scales[name] || 1.0\n const scaleOf = (name: string) => o.scales?.[name] || 1.0;\n const level = how.level(density, \"density\");\n const dimensions = [...level.dimensions] as WvdbVec3;\n const densityData = wvdbTexels(density, level, scaleOf(densityName));\n const makeTexture = (grid: WvdbVolumeGrid, l: WvdbVolumeLevel, data: Uint8Array<ArrayBuffer>, texelBytes: 1 | 4) =>\n how.texture ? how.texture(grid, l, data, texelBytes, mipmaps, scaleOf(grid.name)) : denseTexture(data, dimensions, texelBytes, mipmaps);\n\n const aux = (name: string | undefined, role: \"mask\" | \"albedo\" | \"emission\"): WvdbDenseTexture | null => {\n if (name === undefined) return null;\n const grid = volumeGrid(file, name, role);\n const want = role === \"albedo\" ? 3 : 1;\n if (grid.channels !== want) throw new VDBToolsError(\"VDB_BAD_OPTION\", `wvdbDenseVolume: ${role} grid \"${name}\" has ${grid.channels} channel(s), expected ${want}`);\n const auxLevel = how.level(grid, role);\n if (auxLevel.dimensions.some((v, a) => v !== dimensions[a])) {\n // FrameVolume.js L357–405: raw aux grids are uploaded at the density grid's dimensions.\n throw new VDBToolsError(\"VDB_BAD_OPTION\", \n `wvdbDenseVolume: ${role} grid \"${name}\" LOD ${lod} is ${auxLevel.dimensions.join(\"x\")}, density is ${dimensions.join(\"x\")}; ` +\n \"his renderer uploads aux grids at the density size, so they must match\",\n );\n }\n const data = wvdbTexels(grid, auxLevel, scaleOf(name));\n return makeTexture(grid, auxLevel, data, role === \"albedo\" ? 4 : 1);\n };\n\n // WVDBReader.js L519–523 + WVDBLoader.js L147–152: baked stats when the header has\n // meanDensity and the scale is 1; else WVDBLoader.js L196–198 getDensityStats(data).\n const baked = typeof density.meanDensity === \"number\" && scaleOf(densityName) === 1.0;\n const densityStats: WvdbTexelStats = baked\n ? { sum: density.meanDensity! * density.nonZeroVoxels!, count: density.nonZeroVoxels! }\n : wvdbTexelStats(densityData);\n let max = 0;\n let active = 0;\n for (let i = 0; i < densityData.length; i++) {\n const v = densityData[i]!;\n if (v > max) max = v;\n if (v > 0) active++;\n }\n const densityTexture = makeTexture(density, level, densityData, 1);\n // K4.22: upsampled texels lie between coarse texels, so the coarse LOD's largest bounds them (vdbSrcMaxIn).\n const from = densityTexture.fill?.from.data;\n if (from) for (let i = 0; i < from.length; i++) if (from[i]! > max) max = from[i]!;\n\n return {\n kind: \"dense\",\n normalize: \"clamp01\",\n lod,\n dimensions,\n bbox: density.bbox,\n density: densityTexture,\n mask: aux(o.mask, \"mask\"),\n albedo: aux(o.albedo, \"albedo\"),\n emission: aux(o.emission, \"emission\"),\n densityStats,\n densityStatsSource: baked ? \"baked\" : \"texels\",\n // FrameVolume.js L65–75 getMeanDensity (one volume)\n meanDensity: densityStats.count > 0 ? densityStats.sum / densityStats.count : 0.0,\n maxDensity: max / 255,\n activeTexels: active,\n gridNames: {\n density: densityName,\n ...(o.mask !== undefined ? { mask: o.mask } : {}),\n ...(o.albedo !== undefined ? { albedo: o.albedo } : {}),\n ...(o.emission !== undefined ? { emission: o.emission } : {}),\n },\n };\n}\n\n/** FrameVolume.js L561–568 `getDensityScale`: `densityScale / meanDensity` with `normalizeDensity`. */\nexport function wvdbDensityScale(volume: Pick<WvdbDenseVolume, \"meanDensity\">, densityScale = 1.0, normalizeDensity = true): number {\n return normalizeDensity && volume.meanDensity > 0.0 ? densityScale / volume.meanDensity : densityScale;\n}\n\n// ---------------------------------------------------------------------------\n// CPU twin of the dense source's sampling (vdbSrcDensity & co. in core)\n// ---------------------------------------------------------------------------\n\n/** Linear filtering, clamp to edge, of one channel at uvw in [0, 1]³ (texel centres at (i + 0.5) / size). */\nfunction linear(data: Uint8Array, dims: readonly number[], texelBytes: number, channel: number, u: number, v: number, w: number): number {\n // dims: the sampled texture's size (for the mip atlas, the whole atlas: its taps clamp at the atlas edge, not the level's).\n const [W, H, D] = dims as WvdbVec3;\n const fx = u * W - 0.5;\n const fy = v * H - 0.5;\n const fz = w * D - 0.5;\n const x0 = Math.floor(fx);\n const y0 = Math.floor(fy);\n const z0 = Math.floor(fz);\n const tx = fx - x0;\n const ty = fy - y0;\n const tz = fz - z0;\n const cl = (i: number, n: number) => Math.min(Math.max(i, 0), n - 1);\n const at = (x: number, y: number, z: number) => data[(cl(x, W) + (cl(y, H) + cl(z, D) * H) * W) * texelBytes + channel]! / 255;\n const c00 = at(x0, y0, z0) * (1 - tx) + at(x0 + 1, y0, z0) * tx;\n const c10 = at(x0, y0 + 1, z0) * (1 - tx) + at(x0 + 1, y0 + 1, z0) * tx;\n const c01 = at(x0, y0, z0 + 1) * (1 - tx) + at(x0 + 1, y0, z0 + 1) * tx;\n const c11 = at(x0, y0 + 1, z0 + 1) * (1 - tx) + at(x0 + 1, y0 + 1, z0 + 1) * tx;\n const c0 = c00 * (1 - ty) + c10 * ty;\n const c1 = c01 * (1 - ty) + c11 * ty;\n return c0 * (1 - tz) + c1 * tz;\n}\n\n/** frameShaderChunks.js L838–846 `sampleMipAtlas` (level ≥ 1). */\nfunction sampleMipAtlasCpu(tex: WvdbDenseTexture, level: number, uvw: readonly number[], channel: number): number {\n const atlas = tex.mip!;\n const [AW, AH, AD] = atlas.dimensions;\n const size = tex.dimensions.map((t) => Math.max(1, Math.ceil(t / 2 ** level)));\n const offset = AW - AW / 2 ** (level - 1);\n const texel = uvw.map((c, a) => Math.min(Math.max(c * size[a]!, 0.5), size[a]! - 0.5));\n return linear(atlas.data, [AW, AH, AD], tex.texelBytes, channel, (texel[0]! + offset) / AW, texel[1]! / AH, texel[2]! / AD);\n}\n\n/**\n * CPU twin of the dense source's read at `uvw` (already offset and wrapped) and\n * `lod` (frameShaderChunks.js L849–877 `sampleMipmapped` / `sample3D`): hardware\n * trilinear on the 8-bit texels (as normalized floats), and with mip levels a\n * linear blend of the two nearest levels from the atlas. Real GPUs filter with\n * limited weight precision (typically 8 fractional bits), so compare with a\n * tolerance of about 1/255 of the local value range.\n */\nexport function sampleWvdbDenseTexture(tex: WvdbDenseTexture, uvw: readonly number[], lod = 0, channel = 0): number {\n const levels = tex.mip?.levels ?? 0;\n const base = () => linear(tex.data, tex.dimensions, tex.texelBytes, channel, uvw[0]!, uvw[1]!, uvw[2]!);\n if (levels === 0) return base();\n const level = Math.min(lod, levels);\n if (level <= 0) return base();\n const level0 = Math.floor(level);\n const low = level0 < 0.5 ? base() : sampleMipAtlasCpu(tex, level0, uvw, channel);\n const high = sampleMipAtlasCpu(tex, Math.min(level0 + 1, levels), uvw, channel);\n return low + (high - low) * (level - level0);\n}\n"]}
|
|
@@ -26,82 +26,141 @@ export declare const WVDB_PREAMBLE_SIZE = 12;
|
|
|
26
26
|
export declare const WVDB_SUPPORTED_VERSIONS: readonly [1, 2];
|
|
27
27
|
/** First version with points grids. */
|
|
28
28
|
export declare const WVDB_POINTS_VERSION = 2;
|
|
29
|
+
/** Voxels per brick edge (spec §3.3). */
|
|
29
30
|
export declare const WVDB_BRICK_DIM = 8;
|
|
31
|
+
/** Voxels per brick: `WVDB_BRICK_DIM` cubed. */
|
|
30
32
|
export declare const WVDB_BRICK_VOXELS = 512;
|
|
31
33
|
/** Points of one points page chunk, as his writer chooses (`1 << 18`). */
|
|
32
34
|
export declare const WVDB_POINTS_PAGE: number;
|
|
35
|
+
/** Three numbers: a dimension triple, a position or an RGB value. */
|
|
33
36
|
export type WvdbVec3 = [number, number, number];
|
|
34
37
|
/** `[[minX, minY, minZ], [maxX, maxY, maxZ]]` in world units. */
|
|
35
38
|
export type WvdbBox = [WvdbVec3, WvdbVec3];
|
|
39
|
+
/** How a LOD stores its bricks: every brick (`dense`) or only the non-empty ones, listed by a mask (`sparse`). */
|
|
36
40
|
export type WvdbLayout = "dense" | "sparse";
|
|
41
|
+
/** Bits per stored density sample: 8 or 16 (spec §3). */
|
|
37
42
|
export type WvdbBits = 8 | 16;
|
|
38
43
|
/** Grid classes the spec names; any other string reads as `"unknown"` (spec §5.4). */
|
|
39
44
|
export type WvdbGridClass = "fog volume" | "level set" | "staggered" | "unknown";
|
|
45
|
+
/** A byte range of the file's data section (the compressed chunk of one page or mask). */
|
|
40
46
|
export interface WvdbChunkRef {
|
|
47
|
+
/** Byte offset from the start of the data section. */
|
|
41
48
|
offset: number;
|
|
49
|
+
/** Byte length of the chunk. */
|
|
42
50
|
length: number;
|
|
43
51
|
}
|
|
52
|
+
/** A page of a volume LOD: a chunk that holds up to `bake.pageBricks` bricks. */
|
|
44
53
|
export interface WvdbPageRef extends WvdbChunkRef {
|
|
54
|
+
/** Bricks in this page. */
|
|
45
55
|
bricks: number;
|
|
46
56
|
}
|
|
57
|
+
/** A page of a points LOD: a chunk that holds up to `WVDB_POINTS_PAGE` points. */
|
|
47
58
|
export interface WvdbPointsPageRef extends WvdbChunkRef {
|
|
59
|
+
/** Points in this page. */
|
|
48
60
|
points: number;
|
|
49
61
|
}
|
|
62
|
+
/** The header record of one LOD of a volume grid. */
|
|
50
63
|
export interface WvdbVolumeLodHeader {
|
|
64
|
+
/** Voxels per axis at this LOD. */
|
|
51
65
|
dimensions: WvdbVec3;
|
|
66
|
+
/** Bricks stored (all of them for the dense layout, the non-empty ones for the sparse layout). */
|
|
52
67
|
bricks: number;
|
|
53
68
|
/** Present iff the LOD has the sparse layout. */
|
|
54
69
|
mask?: WvdbChunkRef;
|
|
70
|
+
/** The brick pages, in order. */
|
|
55
71
|
pages: WvdbPageRef[];
|
|
56
72
|
}
|
|
73
|
+
/** The header record of a volume grid. */
|
|
57
74
|
export interface WvdbVolumeGridHeader {
|
|
75
|
+
/** The OpenVDB grid name. */
|
|
58
76
|
name: string;
|
|
77
|
+
/** `"volume"`; absent in version 1 files. */
|
|
59
78
|
type?: "volume";
|
|
79
|
+
/** The OpenVDB grid class as a string (see {@link WvdbGridClass}). */
|
|
60
80
|
class: string;
|
|
81
|
+
/** Channels per voxel: 1 (scalar) or 3 (vector). Default 1. */
|
|
61
82
|
channels?: 1 | 3;
|
|
83
|
+
/** The value of voxels outside the grid, a number or an RGB triple. */
|
|
62
84
|
background: number | WvdbVec3;
|
|
85
|
+
/** The grid's active-voxel box in world units, or null when it has none. */
|
|
63
86
|
bbox: WvdbBox | null;
|
|
87
|
+
/** Mean density over the baked box, when the baker recorded it. */
|
|
64
88
|
meanDensity?: number;
|
|
89
|
+
/** Count of voxels with a non-zero density, when the baker recorded it. */
|
|
65
90
|
nonZeroVoxels?: number;
|
|
91
|
+
/** The LODs, coarse first (LOD `bake.lods - 1` is the finest). */
|
|
66
92
|
lods: WvdbVolumeLodHeader[];
|
|
67
93
|
}
|
|
94
|
+
/** The header record of one LOD of a points grid. */
|
|
68
95
|
export interface WvdbPointsLodHeader {
|
|
96
|
+
/** Points stored in this LOD's pages (the ones it adds to the coarser LODs). */
|
|
69
97
|
points: number;
|
|
98
|
+
/** The point pages, in order. */
|
|
70
99
|
pages: WvdbPointsPageRef[];
|
|
71
100
|
}
|
|
101
|
+
/** The header record of a points grid (version 2). */
|
|
72
102
|
export interface WvdbPointsGridHeader {
|
|
103
|
+
/** The OpenVDB grid name. */
|
|
73
104
|
name: string;
|
|
105
|
+
/** Always `"points"`. */
|
|
74
106
|
type: "points";
|
|
107
|
+
/** The OpenVDB grid class as a string. */
|
|
75
108
|
class: string;
|
|
109
|
+
/** Points in the grid, all LODs together. */
|
|
76
110
|
count: number;
|
|
111
|
+
/** Points in the source grid before `bake.maxPoints` thinned them. */
|
|
77
112
|
sourceCount?: number;
|
|
113
|
+
/** Mean point spacing in world units. */
|
|
78
114
|
spacing?: number;
|
|
115
|
+
/** True when each point carries an RGB colour. */
|
|
79
116
|
colors: boolean;
|
|
117
|
+
/** The points' box in world units, or null for an empty grid. */
|
|
80
118
|
bbox: WvdbBox | null;
|
|
119
|
+
/** The LODs, coarse first (LOD `bake.lods - 1` is the finest). */
|
|
81
120
|
lods: WvdbPointsLodHeader[];
|
|
82
121
|
}
|
|
122
|
+
/** A grid's header record: a volume or a points grid (tell them apart with {@link isPointsGridHeader}). */
|
|
83
123
|
export type WvdbGridHeader = WvdbVolumeGridHeader | WvdbPointsGridHeader;
|
|
124
|
+
/** The settings a file was baked with (spec §5.2). */
|
|
84
125
|
export interface WvdbBake {
|
|
126
|
+
/** Names of the grids baked, or null for every grid in the source. */
|
|
85
127
|
grids: string[] | null;
|
|
128
|
+
/** Voxels along the longest axis of the finest LOD. */
|
|
86
129
|
resolution: number;
|
|
130
|
+
/** Number of LODs baked. */
|
|
87
131
|
lods: number;
|
|
132
|
+
/** Bits per density sample. */
|
|
88
133
|
bits: WvdbBits;
|
|
134
|
+
/** Brick layout of the volume LODs. */
|
|
89
135
|
layout: WvdbLayout;
|
|
136
|
+
/** Bricks per page. */
|
|
90
137
|
pageBricks: number;
|
|
138
|
+
/** The box that was baked, in world units, or null for the grid's own box. */
|
|
91
139
|
bbox?: WvdbBox | null;
|
|
140
|
+
/** Cap on the points kept per points grid. */
|
|
92
141
|
maxPoints?: number;
|
|
93
142
|
}
|
|
143
|
+
/** The file a `.wvdb` was baked from. */
|
|
94
144
|
export interface WvdbSource {
|
|
145
|
+
/** The source file's name. */
|
|
95
146
|
file: string;
|
|
147
|
+
/** SHA-256 of the source file, hex. */
|
|
96
148
|
sha256: string;
|
|
97
149
|
}
|
|
150
|
+
/** The JSON header of a `.wvdb` file (spec §5). */
|
|
98
151
|
export interface WvdbHeader {
|
|
152
|
+
/** File version: 1, or 2 when the file has points grids. */
|
|
99
153
|
version: number;
|
|
154
|
+
/** The file this one was baked from. */
|
|
100
155
|
source: WvdbSource;
|
|
156
|
+
/** The bake settings. */
|
|
101
157
|
bake: WvdbBake;
|
|
158
|
+
/** Voxels per brick edge (8). */
|
|
102
159
|
brickDim: number;
|
|
160
|
+
/** One header per grid. */
|
|
103
161
|
grids: WvdbGridHeader[];
|
|
104
162
|
}
|
|
163
|
+
/** Narrows a {@link WvdbGridHeader} to a points grid. */
|
|
105
164
|
export declare const isPointsGridHeader: (grid: WvdbGridHeader) => grid is WvdbPointsGridHeader;
|
|
106
165
|
export declare function brickCounts([x, y, z]: readonly number[]): WvdbVec3;
|
|
107
166
|
export declare function brickTotal(dimensions: readonly number[]): number;
|
|
@@ -26,11 +26,14 @@ export const WVDB_PREAMBLE_SIZE = 12;
|
|
|
26
26
|
export const WVDB_SUPPORTED_VERSIONS = [1, 2];
|
|
27
27
|
/** First version with points grids. */
|
|
28
28
|
export const WVDB_POINTS_VERSION = 2;
|
|
29
|
+
/** Voxels per brick edge (spec §3.3). */
|
|
29
30
|
export const WVDB_BRICK_DIM = 8;
|
|
31
|
+
/** Voxels per brick: `WVDB_BRICK_DIM` cubed. */
|
|
30
32
|
export const WVDB_BRICK_VOXELS = 512;
|
|
31
33
|
/** Points of one points page chunk, as his writer chooses (`1 << 18`). */
|
|
32
34
|
export const WVDB_POINTS_PAGE = 1 << 18;
|
|
33
35
|
const POINT_CODE_MAX = 0xffff;
|
|
36
|
+
/** Narrows a {@link WvdbGridHeader} to a points grid. */
|
|
34
37
|
export const isPointsGridHeader = (grid) => grid.type === "points";
|
|
35
38
|
// ---------------------------------------------------------------------------
|
|
36
39
|
// Brick math (spec §3.3)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/tools/wvdb/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,oBAAoB;AACpB,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC;AACjC,sCAAsC;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AACrC,+FAA+F;AAC/F,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,EAAE,CAAC,CAAU,CAAC;AACvD,uCAAuC;AACvC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAChC,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACrC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,CAAC;AACxC,MAAM,cAAc,GAAG,MAAM,CAAC;AAoF9B,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAoB,EAAgC,EAAE,CACvF,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;AAEzB,8EAA8E;AAC9E,yBAAyB;AACzB,8EAA8E;AAE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the chunk codecs: page, mask and points chunks (spec §3.3, §6, §7).\n *\n * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345:\n * `src/openvdb/wvdb/format.js` (encodeWVDBPage / decodeWVDBPage /\n * encodeWVDBMask / encodeWVDBPoints / decodeWVDBPoints). Written from the spec\n * (`src/docs/wvdb/README.md` at that commit); where the spec leaves a choice,\n * these follow his code so our bytes and decoded values match his:\n * - min/max of a brick channel are taken over float32 values in float64 and\n * then `Math.fround`ed; `scale = maxCode / (max - min)` in float64.\n * - `Math.round` (halves toward +infinity) for every code, as the spec says.\n * - decode computes `min + code * ((max - min) / maxCode)` in float64 and\n * stores the float32 result; the end codes return min and max exactly.\n * - a point colour that is not finite encodes as 1.0 (his encoder; the spec\n * is silent on NaN).\n *\n * No `three`, no `node:` imports: Node and browser.\n */\n\nimport { WvdbFormatError } from \"../errors.js\";\n\n/** ASCII `WVDB`. */\nexport const WVDB_MAGIC = \"WVDB\";\n/** Magic + version + headerLength. */\nexport const WVDB_PREAMBLE_SIZE = 12;\n/** Versions this reader understands (spec §11). Writers use 1 without points grids, 2 with. */\nexport const WVDB_SUPPORTED_VERSIONS = [1, 2] as const;\n/** First version with points grids. */\nexport const WVDB_POINTS_VERSION = 2;\n\nexport const WVDB_BRICK_DIM = 8;\nexport const WVDB_BRICK_VOXELS = 512;\n/** Points of one points page chunk, as his writer chooses (`1 << 18`). */\nexport const WVDB_POINTS_PAGE = 1 << 18;\nconst POINT_CODE_MAX = 0xffff;\n\nexport type WvdbVec3 = [number, number, number];\n/** `[[minX, minY, minZ], [maxX, maxY, maxZ]]` in world units. */\nexport type WvdbBox = [WvdbVec3, WvdbVec3];\nexport type WvdbLayout = \"dense\" | \"sparse\";\nexport type WvdbBits = 8 | 16;\n/** Grid classes the spec names; any other string reads as `\"unknown\"` (spec §5.4). */\nexport type WvdbGridClass = \"fog volume\" | \"level set\" | \"staggered\" | \"unknown\";\n\nexport interface WvdbChunkRef {\n offset: number;\n length: number;\n}\nexport interface WvdbPageRef extends WvdbChunkRef {\n bricks: number;\n}\nexport interface WvdbPointsPageRef extends WvdbChunkRef {\n points: number;\n}\n\nexport interface WvdbVolumeLodHeader {\n dimensions: WvdbVec3;\n bricks: number;\n /** Present iff the LOD has the sparse layout. */\n mask?: WvdbChunkRef;\n pages: WvdbPageRef[];\n}\n\nexport interface WvdbVolumeGridHeader {\n name: string;\n type?: \"volume\";\n class: string;\n channels?: 1 | 3;\n background: number | WvdbVec3;\n bbox: WvdbBox | null;\n meanDensity?: number;\n nonZeroVoxels?: number;\n lods: WvdbVolumeLodHeader[];\n}\n\nexport interface WvdbPointsLodHeader {\n points: number;\n pages: WvdbPointsPageRef[];\n}\n\nexport interface WvdbPointsGridHeader {\n name: string;\n type: \"points\";\n class: string;\n count: number;\n sourceCount?: number;\n spacing?: number;\n colors: boolean;\n bbox: WvdbBox | null;\n lods: WvdbPointsLodHeader[];\n}\n\nexport type WvdbGridHeader = WvdbVolumeGridHeader | WvdbPointsGridHeader;\n\nexport interface WvdbBake {\n grids: string[] | null;\n resolution: number;\n lods: number;\n bits: WvdbBits;\n layout: WvdbLayout;\n pageBricks: number;\n bbox?: WvdbBox | null;\n maxPoints?: number;\n}\n\nexport interface WvdbSource {\n file: string;\n sha256: string;\n}\n\nexport interface WvdbHeader {\n version: number;\n source: WvdbSource;\n bake: WvdbBake;\n brickDim: number;\n grids: WvdbGridHeader[];\n}\n\nexport const isPointsGridHeader = (grid: WvdbGridHeader): grid is WvdbPointsGridHeader =>\n grid.type === \"points\";\n\n// ---------------------------------------------------------------------------\n// Brick math (spec §3.3)\n// ---------------------------------------------------------------------------\n\nexport function brickCounts([x, y, z]: readonly number[]): WvdbVec3 {\n return [Math.ceil(x! / WVDB_BRICK_DIM), Math.ceil(y! / WVDB_BRICK_DIM), Math.ceil(z! / WVDB_BRICK_DIM)];\n}\n\nexport function brickTotal(dimensions: readonly number[]): number {\n const [cx, cy, cz] = brickCounts(dimensions);\n return cx * cy * cz;\n}\n\n/** First voxel of brick `index` (x fastest, then y, then z). */\nexport function brickOrigin(dimensions: readonly number[], index: number): WvdbVec3 {\n const [countX, countY] = brickCounts(dimensions);\n return [\n (index % countX) * WVDB_BRICK_DIM,\n (Math.floor(index / countX) % countY) * WVDB_BRICK_DIM,\n Math.floor(index / (countX * countY)) * WVDB_BRICK_DIM,\n ];\n}\n\n/** Appendix B: inflated page size. `varying` = brick channels with min !== max. */\nexport function pageByteSize(\n count: number,\n channels: number,\n bits: WvdbBits,\n sparse: boolean,\n varying: number,\n): number {\n return 4 + (sparse ? 4 * count : 0) + 8 * count * channels + varying * WVDB_BRICK_VOXELS * (bits / 8);\n}\n\n/** Appendix B: inflated points chunk size. */\nexport function pointsChunkByteSize(count: number, colors: boolean): number {\n return 4 + 24 + 6 * count + (colors ? 3 * count : 0);\n}\n\n/** §6.3: inflated mask size. */\nexport function maskByteSize(total: number): number {\n return Math.ceil(total / 32) * 4;\n}\n\n// ---------------------------------------------------------------------------\n// Page chunk (spec §6.2, §7)\n// ---------------------------------------------------------------------------\n\n/** One brick for the encoder: `values` holds 512 values per channel, one channel after the other. */\nexport interface WvdbBrickInput {\n index: number;\n values: Float32Array;\n}\n\nexport function encodePage(\n bricks: readonly WvdbBrickInput[],\n { layout, bits, channels }: { layout: WvdbLayout; bits: WvdbBits; channels: number },\n): Uint8Array {\n const sparse = layout === \"sparse\";\n const count = bricks.length;\n const codeSize = bits / 8;\n const maxCode = bits === 16 ? 0xffff : 0xff;\n const ranges = count * channels;\n const mins = new Float64Array(ranges);\n const maxs = new Float64Array(ranges);\n let varying = 0;\n\n for (let b = 0; b < count; b++) {\n const values = bricks[b]!.values;\n for (let c = 0; c < channels; c++) {\n let min = Infinity;\n let max = -Infinity;\n const end = (c + 1) * WVDB_BRICK_VOXELS;\n for (let i = c * WVDB_BRICK_VOXELS; i < end; i++) {\n // Math.min/max (not `<`) so -0 and 0 order exactly as in his encoder.\n min = Math.min(min, values[i]!);\n max = Math.max(max, values[i]!);\n }\n mins[b * channels + c] = Math.fround(min);\n maxs[b * channels + c] = Math.fround(max);\n if (mins[b * channels + c] !== maxs[b * channels + c]) varying++;\n }\n }\n\n const size = pageByteSize(count, channels, bits, sparse, varying);\n const out = new Uint8Array(size);\n const view = new DataView(out.buffer);\n let offset = 0;\n view.setUint32(offset, count, true);\n offset += 4;\n if (sparse) {\n for (const { index } of bricks) {\n view.setUint32(offset, index, true);\n offset += 4;\n }\n }\n for (let i = 0; i < ranges; i++, offset += 4) view.setFloat32(offset, mins[i]!, true);\n for (let i = 0; i < ranges; i++, offset += 4) view.setFloat32(offset, maxs[i]!, true);\n\n for (let b = 0; b < count; b++) {\n const values = bricks[b]!.values;\n for (let c = 0; c < channels; c++) {\n const min = mins[b * channels + c]!;\n const max = maxs[b * channels + c]!;\n if (min === max) continue;\n const scale = maxCode / (max - min);\n const end = (c + 1) * WVDB_BRICK_VOXELS;\n for (let i = c * WVDB_BRICK_VOXELS; i < end; i++) {\n const code = Math.min(Math.max(Math.round((values[i]! - min) * scale), 0), maxCode);\n if (codeSize === 2) view.setUint16(offset, code, true);\n else out[offset] = code;\n offset += codeSize;\n }\n }\n }\n return out;\n}\n\nexport interface DecodedPage {\n /** Brick indices, in page order. */\n indices: Uint32Array;\n /** Brick channel ranges, `b * channels + c`. */\n mins: Float32Array;\n maxs: Float32Array;\n /** 512 decoded values per brick channel, in brick channel order (brick 0 channel 0, brick 0 channel 1, ...). */\n values: Float32Array;\n}\n\n/**\n * Decodes one inflated page and validates its size exactly (Appendix B,\n * §14). `firstIndex` gives the implicit indices of a dense page.\n */\nexport function decodePage(\n bytes: Uint8Array,\n opts: { layout: WvdbLayout; bits: WvdbBits; channels: number; count: number; firstIndex: number; brickTotal: number },\n): DecodedPage {\n const { layout, bits, channels, count, firstIndex, brickTotal: total } = opts;\n const sparse = layout === \"sparse\";\n const fixed = pageByteSize(count, channels, bits, sparse, 0);\n if (bytes.byteLength < fixed) {\n throw new WvdbFormatError(`page: ${bytes.byteLength} bytes, expected at least ${fixed} for ${count} bricks`);\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const stored = view.getUint32(0, true);\n if (stored !== count) {\n throw new WvdbFormatError(`page: brickCount ${stored} does not match the header (${count})`);\n }\n let offset = 4;\n const indices = new Uint32Array(count);\n for (let i = 0; i < count; i++) {\n if (sparse) {\n indices[i] = view.getUint32(offset, true);\n offset += 4;\n } else {\n indices[i] = firstIndex + i;\n }\n if (indices[i]! >= total) {\n throw new WvdbFormatError(`page: brick index ${indices[i]} is not less than brickTotal ${total}`);\n }\n }\n const ranges = count * channels;\n const mins = new Float32Array(ranges);\n const maxs = new Float32Array(ranges);\n for (let i = 0; i < ranges; i++, offset += 4) mins[i] = view.getFloat32(offset, true);\n for (let i = 0; i < ranges; i++, offset += 4) maxs[i] = view.getFloat32(offset, true);\n let varying = 0;\n for (let i = 0; i < ranges; i++) if (mins[i] !== maxs[i]) varying++;\n const expected = pageByteSize(count, channels, bits, sparse, varying);\n if (bytes.byteLength !== expected) {\n throw new WvdbFormatError(`page: ${bytes.byteLength} bytes, expected ${expected} (Appendix B)`);\n }\n\n const maxCode = bits === 16 ? 0xffff : 0xff;\n const values = new Float32Array(ranges * WVDB_BRICK_VOXELS);\n for (let i = 0; i < ranges; i++) {\n const min = mins[i]!;\n const max = maxs[i]!;\n const target = i * WVDB_BRICK_VOXELS;\n if (min === max) {\n values.fill(min, target, target + WVDB_BRICK_VOXELS);\n continue;\n }\n const step = (max - min) / maxCode;\n for (let v = 0; v < WVDB_BRICK_VOXELS; v++) {\n let code: number;\n if (bits === 16) {\n code = view.getUint16(offset, true);\n offset += 2;\n } else {\n code = bytes[offset]!;\n offset += 1;\n }\n values[target + v] = code === maxCode ? max : min + code * step;\n }\n }\n return { indices, mins, maxs, values };\n}\n\n// ---------------------------------------------------------------------------\n// Mask chunk (spec §6.3)\n// ---------------------------------------------------------------------------\n\nexport function encodeMask(indices: Iterable<number>, total: number): Uint8Array {\n const words = new Uint32Array(Math.ceil(total / 32));\n for (const index of indices) words[index >>> 5]! |= 1 << (index & 31);\n const out = new Uint8Array(words.length * 4);\n const view = new DataView(out.buffer);\n words.forEach((word, i) => view.setUint32(i * 4, word, true));\n return out;\n}\n\nexport function decodeMask(bytes: Uint8Array, total: number): Uint32Array {\n const expected = maskByteSize(total);\n if (bytes.byteLength !== expected) {\n throw new WvdbFormatError(`mask: ${bytes.byteLength} bytes, expected ${expected}`);\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const words = new Uint32Array(expected >>> 2);\n for (let i = 0; i < words.length; i++) words[i] = view.getUint32(i * 4, true);\n const tail = total & 31;\n if (tail !== 0 && (words[words.length - 1]! >>> tail) !== 0) {\n throw new WvdbFormatError(`mask: bits after brick ${total - 1} are set`);\n }\n return words;\n}\n\nexport const isMaskBitSet = (words: Uint32Array, index: number): boolean =>\n (words[index >>> 5]! & (1 << (index & 31))) !== 0;\n\n// ---------------------------------------------------------------------------\n// Points chunk (spec §6.4)\n// ---------------------------------------------------------------------------\n\n/** `positions`: xyz per point. `colors`: rgb per point in [0, 1], or null. */\nexport function encodePoints(positions: Float32Array, colors: Float32Array | null): Uint8Array {\n const count = positions.length / 3;\n const out = new Uint8Array(pointsChunkByteSize(count, !!colors));\n const view = new DataView(out.buffer);\n view.setUint32(0, count, true);\n for (let axis = 0; axis < 3; axis++) {\n let min = Infinity;\n let max = -Infinity;\n for (let p = 0; p < count; p++) {\n min = Math.min(min, positions[p * 3 + axis]!);\n max = Math.max(max, positions[p * 3 + axis]!);\n }\n min = count > 0 ? Math.fround(min) : 0;\n max = count > 0 ? Math.fround(max) : 0;\n view.setFloat32(4 + axis * 4, min, true);\n view.setFloat32(16 + axis * 4, max, true);\n const scale = min === max ? 0 : POINT_CODE_MAX / (max - min);\n const high = 28 + axis * 2 * count;\n const low = high + count;\n for (let p = 0; p < count; p++) {\n const code = Math.min(Math.max(Math.round((positions[p * 3 + axis]! - min) * scale), 0), POINT_CODE_MAX);\n out[high + p] = code >>> 8;\n out[low + p] = code & 0xff;\n }\n }\n if (colors) {\n const start = 28 + 6 * count;\n for (let c = 0; c < 3; c++) {\n for (let p = 0; p < count; p++) {\n const v = colors[p * 3 + c]!;\n out[start + c * count + p] = Math.round(Math.min(Math.max(Number.isFinite(v) ? v : 1, 0), 1) * 255);\n }\n }\n }\n return out;\n}\n\nexport interface DecodedPoints {\n positions: Float32Array;\n colors: Float32Array | null;\n}\n\nexport function decodePoints(bytes: Uint8Array, { count, colors }: { count: number; colors: boolean }): DecodedPoints {\n const expected = pointsChunkByteSize(count, colors);\n if (bytes.byteLength !== expected) {\n throw new WvdbFormatError(`points: ${bytes.byteLength} bytes, expected ${expected}`);\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const stored = view.getUint32(0, true);\n if (stored !== count) {\n throw new WvdbFormatError(`points: pointCount ${stored} does not match the header (${count})`);\n }\n const positions = new Float32Array(count * 3);\n for (let axis = 0; axis < 3; axis++) {\n const min = view.getFloat32(4 + axis * 4, true);\n const max = view.getFloat32(16 + axis * 4, true);\n const step = (max - min) / POINT_CODE_MAX;\n const high = 28 + axis * 2 * count;\n const low = high + count;\n for (let p = 0; p < count; p++) {\n const code = (bytes[high + p]! << 8) | bytes[low + p]!;\n positions[p * 3 + axis] = code === POINT_CODE_MAX ? max : min + code * step;\n }\n }\n let rgb: Float32Array | null = null;\n if (colors) {\n rgb = new Float32Array(count * 3);\n const start = 28 + 6 * count;\n for (let c = 0; c < 3; c++) {\n for (let p = 0; p < count; p++) rgb[p * 3 + c] = bytes[start + c * count + p]! / 255;\n }\n }\n return { positions, colors: rgb };\n}\n\n/** A `.wvdb` file breaks the spec (bad magic, header, offsets, sizes); defined in `../errors.ts` (D32). */\nexport { WvdbFormatError };\n"]}
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../../src/tools/wvdb/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,eAAe,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ACH,CAAC;IACD,IAAI,GAAG,GAAwB,IAAI,CAAC;IACpC,IAAI,MAAM,EAAE,CAAC;QACX,GAAG,GAAG,IAAI,YAAY,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAClC,MAAM,KAAK,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;QAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE;gBAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAE,GAAG,GAAG,CAAC;QACvF,CAAC;IACH,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AACpC,CAAC;AAED,2GAA2G;AAC3G,OAAO,EAAE,eAAe,EAAE,CAAC","sourcesContent":["/**\n * format.ts — `.wvdb` (WebVDB, mjurczyk's spec v0.5.x) constants, header types\n * and the chunk codecs: page, mask and points chunks (spec §3.3, §6, §7).\n *\n * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345:\n * `src/openvdb/wvdb/format.js` (encodeWVDBPage / decodeWVDBPage /\n * encodeWVDBMask / encodeWVDBPoints / decodeWVDBPoints). Written from the spec\n * (`src/docs/wvdb/README.md` at that commit); where the spec leaves a choice,\n * these follow his code so our bytes and decoded values match his:\n * - min/max of a brick channel are taken over float32 values in float64 and\n * then `Math.fround`ed; `scale = maxCode / (max - min)` in float64.\n * - `Math.round` (halves toward +infinity) for every code, as the spec says.\n * - decode computes `min + code * ((max - min) / maxCode)` in float64 and\n * stores the float32 result; the end codes return min and max exactly.\n * - a point colour that is not finite encodes as 1.0 (his encoder; the spec\n * is silent on NaN).\n *\n * No `three`, no `node:` imports: Node and browser.\n */\n\nimport { WvdbFormatError } from \"../errors.js\";\n\n/** ASCII `WVDB`. */\nexport const WVDB_MAGIC = \"WVDB\";\n/** Magic + version + headerLength. */\nexport const WVDB_PREAMBLE_SIZE = 12;\n/** Versions this reader understands (spec §11). Writers use 1 without points grids, 2 with. */\nexport const WVDB_SUPPORTED_VERSIONS = [1, 2] as const;\n/** First version with points grids. */\nexport const WVDB_POINTS_VERSION = 2;\n\n/** Voxels per brick edge (spec §3.3). */\nexport const WVDB_BRICK_DIM = 8;\n/** Voxels per brick: `WVDB_BRICK_DIM` cubed. */\nexport const WVDB_BRICK_VOXELS = 512;\n/** Points of one points page chunk, as his writer chooses (`1 << 18`). */\nexport const WVDB_POINTS_PAGE = 1 << 18;\nconst POINT_CODE_MAX = 0xffff;\n\n/** Three numbers: a dimension triple, a position or an RGB value. */\nexport type WvdbVec3 = [number, number, number];\n/** `[[minX, minY, minZ], [maxX, maxY, maxZ]]` in world units. */\nexport type WvdbBox = [WvdbVec3, WvdbVec3];\n/** How a LOD stores its bricks: every brick (`dense`) or only the non-empty ones, listed by a mask (`sparse`). */\nexport type WvdbLayout = \"dense\" | \"sparse\";\n/** Bits per stored density sample: 8 or 16 (spec §3). */\nexport type WvdbBits = 8 | 16;\n/** Grid classes the spec names; any other string reads as `\"unknown\"` (spec §5.4). */\nexport type WvdbGridClass = \"fog volume\" | \"level set\" | \"staggered\" | \"unknown\";\n\n/** A byte range of the file's data section (the compressed chunk of one page or mask). */\nexport interface WvdbChunkRef {\n /** Byte offset from the start of the data section. */\n offset: number;\n /** Byte length of the chunk. */\n length: number;\n}\n/** A page of a volume LOD: a chunk that holds up to `bake.pageBricks` bricks. */\nexport interface WvdbPageRef extends WvdbChunkRef {\n /** Bricks in this page. */\n bricks: number;\n}\n/** A page of a points LOD: a chunk that holds up to `WVDB_POINTS_PAGE` points. */\nexport interface WvdbPointsPageRef extends WvdbChunkRef {\n /** Points in this page. */\n points: number;\n}\n\n/** The header record of one LOD of a volume grid. */\nexport interface WvdbVolumeLodHeader {\n /** Voxels per axis at this LOD. */\n dimensions: WvdbVec3;\n /** Bricks stored (all of them for the dense layout, the non-empty ones for the sparse layout). */\n bricks: number;\n /** Present iff the LOD has the sparse layout. */\n mask?: WvdbChunkRef;\n /** The brick pages, in order. */\n pages: WvdbPageRef[];\n}\n\n/** The header record of a volume grid. */\nexport interface WvdbVolumeGridHeader {\n /** The OpenVDB grid name. */\n name: string;\n /** `\"volume\"`; absent in version 1 files. */\n type?: \"volume\";\n /** The OpenVDB grid class as a string (see {@link WvdbGridClass}). */\n class: string;\n /** Channels per voxel: 1 (scalar) or 3 (vector). Default 1. */\n channels?: 1 | 3;\n /** The value of voxels outside the grid, a number or an RGB triple. */\n background: number | WvdbVec3;\n /** The grid's active-voxel box in world units, or null when it has none. */\n bbox: WvdbBox | null;\n /** Mean density over the baked box, when the baker recorded it. */\n meanDensity?: number;\n /** Count of voxels with a non-zero density, when the baker recorded it. */\n nonZeroVoxels?: number;\n /** The LODs, coarse first (LOD `bake.lods - 1` is the finest). */\n lods: WvdbVolumeLodHeader[];\n}\n\n/** The header record of one LOD of a points grid. */\nexport interface WvdbPointsLodHeader {\n /** Points stored in this LOD's pages (the ones it adds to the coarser LODs). */\n points: number;\n /** The point pages, in order. */\n pages: WvdbPointsPageRef[];\n}\n\n/** The header record of a points grid (version 2). */\nexport interface WvdbPointsGridHeader {\n /** The OpenVDB grid name. */\n name: string;\n /** Always `\"points\"`. */\n type: \"points\";\n /** The OpenVDB grid class as a string. */\n class: string;\n /** Points in the grid, all LODs together. */\n count: number;\n /** Points in the source grid before `bake.maxPoints` thinned them. */\n sourceCount?: number;\n /** Mean point spacing in world units. */\n spacing?: number;\n /** True when each point carries an RGB colour. */\n colors: boolean;\n /** The points' box in world units, or null for an empty grid. */\n bbox: WvdbBox | null;\n /** The LODs, coarse first (LOD `bake.lods - 1` is the finest). */\n lods: WvdbPointsLodHeader[];\n}\n\n/** A grid's header record: a volume or a points grid (tell them apart with {@link isPointsGridHeader}). */\nexport type WvdbGridHeader = WvdbVolumeGridHeader | WvdbPointsGridHeader;\n\n/** The settings a file was baked with (spec §5.2). */\nexport interface WvdbBake {\n /** Names of the grids baked, or null for every grid in the source. */\n grids: string[] | null;\n /** Voxels along the longest axis of the finest LOD. */\n resolution: number;\n /** Number of LODs baked. */\n lods: number;\n /** Bits per density sample. */\n bits: WvdbBits;\n /** Brick layout of the volume LODs. */\n layout: WvdbLayout;\n /** Bricks per page. */\n pageBricks: number;\n /** The box that was baked, in world units, or null for the grid's own box. */\n bbox?: WvdbBox | null;\n /** Cap on the points kept per points grid. */\n maxPoints?: number;\n}\n\n/** The file a `.wvdb` was baked from. */\nexport interface WvdbSource {\n /** The source file's name. */\n file: string;\n /** SHA-256 of the source file, hex. */\n sha256: string;\n}\n\n/** The JSON header of a `.wvdb` file (spec §5). */\nexport interface WvdbHeader {\n /** File version: 1, or 2 when the file has points grids. */\n version: number;\n /** The file this one was baked from. */\n source: WvdbSource;\n /** The bake settings. */\n bake: WvdbBake;\n /** Voxels per brick edge (8). */\n brickDim: number;\n /** One header per grid. */\n grids: WvdbGridHeader[];\n}\n\n/** Narrows a {@link WvdbGridHeader} to a points grid. */\nexport const isPointsGridHeader = (grid: WvdbGridHeader): grid is WvdbPointsGridHeader =>\n grid.type === \"points\";\n\n// ---------------------------------------------------------------------------\n// Brick math (spec §3.3)\n// ---------------------------------------------------------------------------\n\nexport function brickCounts([x, y, z]: readonly number[]): WvdbVec3 {\n return [Math.ceil(x! / WVDB_BRICK_DIM), Math.ceil(y! / WVDB_BRICK_DIM), Math.ceil(z! / WVDB_BRICK_DIM)];\n}\n\nexport function brickTotal(dimensions: readonly number[]): number {\n const [cx, cy, cz] = brickCounts(dimensions);\n return cx * cy * cz;\n}\n\n/** First voxel of brick `index` (x fastest, then y, then z). */\nexport function brickOrigin(dimensions: readonly number[], index: number): WvdbVec3 {\n const [countX, countY] = brickCounts(dimensions);\n return [\n (index % countX) * WVDB_BRICK_DIM,\n (Math.floor(index / countX) % countY) * WVDB_BRICK_DIM,\n Math.floor(index / (countX * countY)) * WVDB_BRICK_DIM,\n ];\n}\n\n/** Appendix B: inflated page size. `varying` = brick channels with min !== max. */\nexport function pageByteSize(\n count: number,\n channels: number,\n bits: WvdbBits,\n sparse: boolean,\n varying: number,\n): number {\n return 4 + (sparse ? 4 * count : 0) + 8 * count * channels + varying * WVDB_BRICK_VOXELS * (bits / 8);\n}\n\n/** Appendix B: inflated points chunk size. */\nexport function pointsChunkByteSize(count: number, colors: boolean): number {\n return 4 + 24 + 6 * count + (colors ? 3 * count : 0);\n}\n\n/** §6.3: inflated mask size. */\nexport function maskByteSize(total: number): number {\n return Math.ceil(total / 32) * 4;\n}\n\n// ---------------------------------------------------------------------------\n// Page chunk (spec §6.2, §7)\n// ---------------------------------------------------------------------------\n\n/** One brick for the encoder: `values` holds 512 values per channel, one channel after the other. */\nexport interface WvdbBrickInput {\n index: number;\n values: Float32Array;\n}\n\nexport function encodePage(\n bricks: readonly WvdbBrickInput[],\n { layout, bits, channels }: { layout: WvdbLayout; bits: WvdbBits; channels: number },\n): Uint8Array {\n const sparse = layout === \"sparse\";\n const count = bricks.length;\n const codeSize = bits / 8;\n const maxCode = bits === 16 ? 0xffff : 0xff;\n const ranges = count * channels;\n const mins = new Float64Array(ranges);\n const maxs = new Float64Array(ranges);\n let varying = 0;\n\n for (let b = 0; b < count; b++) {\n const values = bricks[b]!.values;\n for (let c = 0; c < channels; c++) {\n let min = Infinity;\n let max = -Infinity;\n const end = (c + 1) * WVDB_BRICK_VOXELS;\n for (let i = c * WVDB_BRICK_VOXELS; i < end; i++) {\n // Math.min/max (not `<`) so -0 and 0 order exactly as in his encoder.\n min = Math.min(min, values[i]!);\n max = Math.max(max, values[i]!);\n }\n mins[b * channels + c] = Math.fround(min);\n maxs[b * channels + c] = Math.fround(max);\n if (mins[b * channels + c] !== maxs[b * channels + c]) varying++;\n }\n }\n\n const size = pageByteSize(count, channels, bits, sparse, varying);\n const out = new Uint8Array(size);\n const view = new DataView(out.buffer);\n let offset = 0;\n view.setUint32(offset, count, true);\n offset += 4;\n if (sparse) {\n for (const { index } of bricks) {\n view.setUint32(offset, index, true);\n offset += 4;\n }\n }\n for (let i = 0; i < ranges; i++, offset += 4) view.setFloat32(offset, mins[i]!, true);\n for (let i = 0; i < ranges; i++, offset += 4) view.setFloat32(offset, maxs[i]!, true);\n\n for (let b = 0; b < count; b++) {\n const values = bricks[b]!.values;\n for (let c = 0; c < channels; c++) {\n const min = mins[b * channels + c]!;\n const max = maxs[b * channels + c]!;\n if (min === max) continue;\n const scale = maxCode / (max - min);\n const end = (c + 1) * WVDB_BRICK_VOXELS;\n for (let i = c * WVDB_BRICK_VOXELS; i < end; i++) {\n const code = Math.min(Math.max(Math.round((values[i]! - min) * scale), 0), maxCode);\n if (codeSize === 2) view.setUint16(offset, code, true);\n else out[offset] = code;\n offset += codeSize;\n }\n }\n }\n return out;\n}\n\nexport interface DecodedPage {\n /** Brick indices, in page order. */\n indices: Uint32Array;\n /** Brick channel ranges, `b * channels + c`. */\n mins: Float32Array;\n maxs: Float32Array;\n /** 512 decoded values per brick channel, in brick channel order (brick 0 channel 0, brick 0 channel 1, ...). */\n values: Float32Array;\n}\n\n/**\n * Decodes one inflated page and validates its size exactly (Appendix B,\n * §14). `firstIndex` gives the implicit indices of a dense page.\n */\nexport function decodePage(\n bytes: Uint8Array,\n opts: { layout: WvdbLayout; bits: WvdbBits; channels: number; count: number; firstIndex: number; brickTotal: number },\n): DecodedPage {\n const { layout, bits, channels, count, firstIndex, brickTotal: total } = opts;\n const sparse = layout === \"sparse\";\n const fixed = pageByteSize(count, channels, bits, sparse, 0);\n if (bytes.byteLength < fixed) {\n throw new WvdbFormatError(`page: ${bytes.byteLength} bytes, expected at least ${fixed} for ${count} bricks`);\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const stored = view.getUint32(0, true);\n if (stored !== count) {\n throw new WvdbFormatError(`page: brickCount ${stored} does not match the header (${count})`);\n }\n let offset = 4;\n const indices = new Uint32Array(count);\n for (let i = 0; i < count; i++) {\n if (sparse) {\n indices[i] = view.getUint32(offset, true);\n offset += 4;\n } else {\n indices[i] = firstIndex + i;\n }\n if (indices[i]! >= total) {\n throw new WvdbFormatError(`page: brick index ${indices[i]} is not less than brickTotal ${total}`);\n }\n }\n const ranges = count * channels;\n const mins = new Float32Array(ranges);\n const maxs = new Float32Array(ranges);\n for (let i = 0; i < ranges; i++, offset += 4) mins[i] = view.getFloat32(offset, true);\n for (let i = 0; i < ranges; i++, offset += 4) maxs[i] = view.getFloat32(offset, true);\n let varying = 0;\n for (let i = 0; i < ranges; i++) if (mins[i] !== maxs[i]) varying++;\n const expected = pageByteSize(count, channels, bits, sparse, varying);\n if (bytes.byteLength !== expected) {\n throw new WvdbFormatError(`page: ${bytes.byteLength} bytes, expected ${expected} (Appendix B)`);\n }\n\n const maxCode = bits === 16 ? 0xffff : 0xff;\n const values = new Float32Array(ranges * WVDB_BRICK_VOXELS);\n for (let i = 0; i < ranges; i++) {\n const min = mins[i]!;\n const max = maxs[i]!;\n const target = i * WVDB_BRICK_VOXELS;\n if (min === max) {\n values.fill(min, target, target + WVDB_BRICK_VOXELS);\n continue;\n }\n const step = (max - min) / maxCode;\n for (let v = 0; v < WVDB_BRICK_VOXELS; v++) {\n let code: number;\n if (bits === 16) {\n code = view.getUint16(offset, true);\n offset += 2;\n } else {\n code = bytes[offset]!;\n offset += 1;\n }\n values[target + v] = code === maxCode ? max : min + code * step;\n }\n }\n return { indices, mins, maxs, values };\n}\n\n// ---------------------------------------------------------------------------\n// Mask chunk (spec §6.3)\n// ---------------------------------------------------------------------------\n\nexport function encodeMask(indices: Iterable<number>, total: number): Uint8Array {\n const words = new Uint32Array(Math.ceil(total / 32));\n for (const index of indices) words[index >>> 5]! |= 1 << (index & 31);\n const out = new Uint8Array(words.length * 4);\n const view = new DataView(out.buffer);\n words.forEach((word, i) => view.setUint32(i * 4, word, true));\n return out;\n}\n\nexport function decodeMask(bytes: Uint8Array, total: number): Uint32Array {\n const expected = maskByteSize(total);\n if (bytes.byteLength !== expected) {\n throw new WvdbFormatError(`mask: ${bytes.byteLength} bytes, expected ${expected}`);\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const words = new Uint32Array(expected >>> 2);\n for (let i = 0; i < words.length; i++) words[i] = view.getUint32(i * 4, true);\n const tail = total & 31;\n if (tail !== 0 && (words[words.length - 1]! >>> tail) !== 0) {\n throw new WvdbFormatError(`mask: bits after brick ${total - 1} are set`);\n }\n return words;\n}\n\nexport const isMaskBitSet = (words: Uint32Array, index: number): boolean =>\n (words[index >>> 5]! & (1 << (index & 31))) !== 0;\n\n// ---------------------------------------------------------------------------\n// Points chunk (spec §6.4)\n// ---------------------------------------------------------------------------\n\n/** `positions`: xyz per point. `colors`: rgb per point in [0, 1], or null. */\nexport function encodePoints(positions: Float32Array, colors: Float32Array | null): Uint8Array {\n const count = positions.length / 3;\n const out = new Uint8Array(pointsChunkByteSize(count, !!colors));\n const view = new DataView(out.buffer);\n view.setUint32(0, count, true);\n for (let axis = 0; axis < 3; axis++) {\n let min = Infinity;\n let max = -Infinity;\n for (let p = 0; p < count; p++) {\n min = Math.min(min, positions[p * 3 + axis]!);\n max = Math.max(max, positions[p * 3 + axis]!);\n }\n min = count > 0 ? Math.fround(min) : 0;\n max = count > 0 ? Math.fround(max) : 0;\n view.setFloat32(4 + axis * 4, min, true);\n view.setFloat32(16 + axis * 4, max, true);\n const scale = min === max ? 0 : POINT_CODE_MAX / (max - min);\n const high = 28 + axis * 2 * count;\n const low = high + count;\n for (let p = 0; p < count; p++) {\n const code = Math.min(Math.max(Math.round((positions[p * 3 + axis]! - min) * scale), 0), POINT_CODE_MAX);\n out[high + p] = code >>> 8;\n out[low + p] = code & 0xff;\n }\n }\n if (colors) {\n const start = 28 + 6 * count;\n for (let c = 0; c < 3; c++) {\n for (let p = 0; p < count; p++) {\n const v = colors[p * 3 + c]!;\n out[start + c * count + p] = Math.round(Math.min(Math.max(Number.isFinite(v) ? v : 1, 0), 1) * 255);\n }\n }\n }\n return out;\n}\n\nexport interface DecodedPoints {\n positions: Float32Array;\n colors: Float32Array | null;\n}\n\nexport function decodePoints(bytes: Uint8Array, { count, colors }: { count: number; colors: boolean }): DecodedPoints {\n const expected = pointsChunkByteSize(count, colors);\n if (bytes.byteLength !== expected) {\n throw new WvdbFormatError(`points: ${bytes.byteLength} bytes, expected ${expected}`);\n }\n const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n const stored = view.getUint32(0, true);\n if (stored !== count) {\n throw new WvdbFormatError(`points: pointCount ${stored} does not match the header (${count})`);\n }\n const positions = new Float32Array(count * 3);\n for (let axis = 0; axis < 3; axis++) {\n const min = view.getFloat32(4 + axis * 4, true);\n const max = view.getFloat32(16 + axis * 4, true);\n const step = (max - min) / POINT_CODE_MAX;\n const high = 28 + axis * 2 * count;\n const low = high + count;\n for (let p = 0; p < count; p++) {\n const code = (bytes[high + p]! << 8) | bytes[low + p]!;\n positions[p * 3 + axis] = code === POINT_CODE_MAX ? max : min + code * step;\n }\n }\n let rgb: Float32Array | null = null;\n if (colors) {\n rgb = new Float32Array(count * 3);\n const start = 28 + 6 * count;\n for (let c = 0; c < 3; c++) {\n for (let p = 0; p < count; p++) rgb[p * 3 + c] = bytes[start + c * count + p]! / 255;\n }\n }\n return { positions, colors: rgb };\n}\n\n/** A `.wvdb` file breaks the spec (bad magic, header, offsets, sizes); defined in `../errors.ts` (D32). */\nexport { WvdbFormatError };\n"]}
|
package/dist/tools/wvdb/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/wvdb/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC","sourcesContent":["/**\n * `.wvdb` (mjurczyk's WebVDB format, spec v0.5.x, file versions 1 and 2):\n * read, write, and bake from `.vdb` / NanoVDB. Portions derived from\n * mjurczyk/openvdb (MIT), commit 75e7345 — see each module's header.\n */\nexport * from \"./format.js\";\nexport * from \"./read.js\";\nexport * from \"./write.js\";\nexport * from \"./bake.js\";\nexport * from \"./level-set.js\";\nexport { sha256Hex } from \"./sha256.js\";\nexport * from \"./dense.js\";\nexport * from \"./nanovdb.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/wvdb/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC","sourcesContent":["/**\n * `.wvdb` (mjurczyk's WebVDB format, spec v0.5.x, file versions 1 and 2):\n * read, write, and bake from `.vdb` / NanoVDB. Portions derived from\n * mjurczyk/openvdb (MIT), commit 75e7345 — see each module's header.\n */\nexport * from \"./format.js\";\nexport * from \"./read.js\";\nexport * from \"./write.js\";\nexport * from \"./bake.js\";\nexport * from \"./level-set.js\";\nexport { sha256Hex } from \"./sha256.js\";\nexport * from \"./dense.js\";\nexport * from \"./partial.js\";\nexport * from \"./nanovdb.js\";\n"]}
|
|
@@ -24,9 +24,17 @@
|
|
|
24
24
|
import type { WvdbBits, WvdbBox, WvdbVec3 } from "./format.js";
|
|
25
25
|
/** Index-space access to a sample source (axis-aligned or affine map). */
|
|
26
26
|
export interface WvdbIndexAccess {
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* World position → fractional index coordinate (the grid's inverse map), into `out`.
|
|
29
|
+
* @param world The world position.
|
|
30
|
+
* @param out Receives the index coordinate (returned).
|
|
31
|
+
*/
|
|
28
32
|
toIndex(world: WvdbVec3, out: WvdbVec3): WvdbVec3;
|
|
29
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* A world-space vector → index units (the inverse Jacobian), into `out`.
|
|
35
|
+
* @param vector The world-space vector.
|
|
36
|
+
* @param out Receives the vector in index units (returned).
|
|
37
|
+
*/
|
|
30
38
|
toIndexVector(vector: WvdbVec3, out: WvdbVec3): WvdbVec3;
|
|
31
39
|
/** Value and active state of an integer voxel (inactive tile values included). */
|
|
32
40
|
voxel(ijk: [number, number, number]): {
|