@pmndrs/vdb 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +727 -0
- package/LICENSE +21 -0
- package/README.md +496 -2
- package/THIRD_PARTY_NOTICES.md +315 -0
- package/dist/core/compute/atlas.d.ts +102 -0
- package/dist/core/compute/atlas.js +103 -0
- package/dist/core/compute/atlas.js.map +1 -0
- package/dist/core/compute/index.d.ts +13 -0
- package/dist/core/compute/index.js +9 -0
- package/dist/core/compute/index.js.map +1 -0
- package/dist/core/compute/majorant-build.d.ts +45 -0
- package/dist/core/compute/majorant-build.js +193 -0
- package/dist/core/compute/majorant-build.js.map +1 -0
- package/dist/core/compute/multi-scale.d.ts +155 -0
- package/dist/core/compute/multi-scale.js +684 -0
- package/dist/core/compute/multi-scale.js.map +1 -0
- package/dist/core/compute/pyramid.d.ts +120 -0
- package/dist/core/compute/pyramid.js +468 -0
- package/dist/core/compute/pyramid.js.map +1 -0
- package/dist/core/compute/shared.d.ts +116 -0
- package/dist/core/compute/shared.js +211 -0
- package/dist/core/compute/shared.js.map +1 -0
- package/dist/core/compute/stats.d.ts +78 -0
- package/dist/core/compute/stats.js +193 -0
- package/dist/core/compute/stats.js.map +1 -0
- package/dist/core/compute/value-transform.d.ts +30 -0
- package/dist/core/compute/value-transform.js +64 -0
- package/dist/core/compute/value-transform.js.map +1 -0
- package/dist/core/errors.d.ts +21 -0
- package/dist/core/errors.js +17 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/frame/emission.d.ts +85 -0
- package/dist/core/frame/emission.js +422 -0
- package/dist/core/frame/emission.js.map +1 -0
- package/dist/core/frame/environment.d.ts +47 -0
- package/dist/core/frame/environment.js +178 -0
- package/dist/core/frame/environment.js.map +1 -0
- package/dist/core/frame/index.d.ts +39 -0
- package/dist/core/frame/index.js +27 -0
- package/dist/core/frame/index.js.map +1 -0
- package/dist/core/frame/kernels.d.ts +115 -0
- package/dist/core/frame/kernels.js +496 -0
- package/dist/core/frame/kernels.js.map +1 -0
- package/dist/core/frame/limits.d.ts +67 -0
- package/dist/core/frame/limits.js +109 -0
- package/dist/core/frame/limits.js.map +1 -0
- package/dist/core/frame/phase.d.ts +17 -0
- package/dist/core/frame/phase.js +53 -0
- package/dist/core/frame/phase.js.map +1 -0
- package/dist/core/frame/pipelines.d.ts +49 -0
- package/dist/core/frame/pipelines.js +147 -0
- package/dist/core/frame/pipelines.js.map +1 -0
- package/dist/core/frame/renderer.d.ts +122 -0
- package/dist/core/frame/renderer.js +1712 -0
- package/dist/core/frame/renderer.js.map +1 -0
- package/dist/core/frame/resources.d.ts +71 -0
- package/dist/core/frame/resources.js +100 -0
- package/dist/core/frame/resources.js.map +1 -0
- package/dist/core/frame/scattering.d.ts +97 -0
- package/dist/core/frame/scattering.js +332 -0
- package/dist/core/frame/scattering.js.map +1 -0
- package/dist/core/frame/settings.d.ts +243 -0
- package/dist/core/frame/settings.js +67 -0
- package/dist/core/frame/settings.js.map +1 -0
- package/dist/core/frame/shadows.d.ts +55 -0
- package/dist/core/frame/shadows.js +460 -0
- package/dist/core/frame/shadows.js.map +1 -0
- package/dist/core/frame/types.d.ts +415 -0
- package/dist/core/frame/types.js +49 -0
- package/dist/core/frame/types.js.map +1 -0
- package/dist/core/frame/uniforms.d.ts +105 -0
- package/dist/core/frame/uniforms.js +276 -0
- package/dist/core/frame/uniforms.js.map +1 -0
- package/dist/core/frame/wgsl/chunks.d.ts +4 -0
- package/dist/core/frame/wgsl/chunks.js +728 -0
- package/dist/core/frame/wgsl/chunks.js.map +1 -0
- package/dist/core/frame/wgsl/emission.d.ts +82 -0
- package/dist/core/frame/wgsl/emission.js +353 -0
- package/dist/core/frame/wgsl/emission.js.map +1 -0
- package/dist/core/frame/wgsl/environment.d.ts +42 -0
- package/dist/core/frame/wgsl/environment.js +711 -0
- package/dist/core/frame/wgsl/environment.js.map +1 -0
- package/dist/core/frame/wgsl/gather.d.ts +55 -0
- package/dist/core/frame/wgsl/gather.js +850 -0
- package/dist/core/frame/wgsl/gather.js.map +1 -0
- package/dist/core/frame/wgsl/integrate.d.ts +78 -0
- package/dist/core/frame/wgsl/integrate.js +213 -0
- package/dist/core/frame/wgsl/integrate.js.map +1 -0
- package/dist/core/frame/wgsl/lighting.d.ts +103 -0
- package/dist/core/frame/wgsl/lighting.js +1636 -0
- package/dist/core/frame/wgsl/lighting.js.map +1 -0
- package/dist/core/frame/wgsl/occluders.d.ts +20 -0
- package/dist/core/frame/wgsl/occluders.js +95 -0
- package/dist/core/frame/wgsl/occluders.js.map +1 -0
- package/dist/core/frame/wgsl/resolve.d.ts +19 -0
- package/dist/core/frame/wgsl/resolve.js +205 -0
- package/dist/core/frame/wgsl/resolve.js.map +1 -0
- package/dist/core/frame/wgsl/shadows.d.ts +35 -0
- package/dist/core/frame/wgsl/shadows.js +328 -0
- package/dist/core/frame/wgsl/shadows.js.map +1 -0
- package/dist/core/half.d.ts +11 -0
- package/dist/core/half.js +22 -0
- package/dist/core/half.js.map +1 -0
- package/dist/core/index.d.ts +52 -0
- package/dist/core/index.js +46 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/internal.d.ts +31 -0
- package/dist/core/internal.js +32 -0
- package/dist/core/internal.js.map +1 -0
- package/dist/core/pool/affine.d.ts +34 -0
- package/dist/core/pool/affine.js +100 -0
- package/dist/core/pool/affine.js.map +1 -0
- package/dist/core/pool/allocator.d.ts +32 -0
- package/dist/core/pool/allocator.js +81 -0
- package/dist/core/pool/allocator.js.map +1 -0
- package/dist/core/pool/image-header.d.ts +93 -0
- package/dist/core/pool/image-header.js +194 -0
- package/dist/core/pool/image-header.js.map +1 -0
- package/dist/core/pool/layout.d.ts +198 -0
- package/dist/core/pool/layout.js +316 -0
- package/dist/core/pool/layout.js.map +1 -0
- package/dist/core/pool/limits.d.ts +41 -0
- package/dist/core/pool/limits.js +80 -0
- package/dist/core/pool/limits.js.map +1 -0
- package/dist/core/pool/pool.d.ts +384 -0
- package/dist/core/pool/pool.js +1184 -0
- package/dist/core/pool/pool.js.map +1 -0
- package/dist/core/reference/index.d.ts +6 -0
- package/dist/core/reference/index.js +7 -0
- package/dist/core/reference/index.js.map +1 -0
- package/dist/core/reference/renderer.d.ts +105 -0
- package/dist/core/reference/renderer.js +474 -0
- package/dist/core/reference/renderer.js.map +1 -0
- package/dist/core/reference/wgsl.d.ts +65 -0
- package/dist/core/reference/wgsl.js +803 -0
- package/dist/core/reference/wgsl.js.map +1 -0
- package/dist/core/sequence.d.ts +347 -0
- package/dist/core/sequence.js +548 -0
- package/dist/core/sequence.js.map +1 -0
- package/dist/core/source/brick-cache.d.ts +165 -0
- package/dist/core/source/brick-cache.js +627 -0
- package/dist/core/source/brick-cache.js.map +1 -0
- package/dist/core/source/dense-fill.d.ts +53 -0
- package/dist/core/source/dense-fill.js +377 -0
- package/dist/core/source/dense-fill.js.map +1 -0
- package/dist/core/source/dense.d.ts +50 -0
- package/dist/core/source/dense.js +384 -0
- package/dist/core/source/dense.js.map +1 -0
- package/dist/core/source/sparse-wgsl.d.ts +92 -0
- package/dist/core/source/sparse-wgsl.js +481 -0
- package/dist/core/source/sparse-wgsl.js.map +1 -0
- package/dist/core/source/sparse.d.ts +192 -0
- package/dist/core/source/sparse.js +762 -0
- package/dist/core/source/sparse.js.map +1 -0
- package/dist/core/source/types.d.ts +120 -0
- package/dist/core/source/types.js +9 -0
- package/dist/core/source/types.js.map +1 -0
- package/dist/core/surface/index.d.ts +10 -0
- package/dist/core/surface/index.js +9 -0
- package/dist/core/surface/index.js.map +1 -0
- package/dist/core/surface/level-set-pass.d.ts +140 -0
- package/dist/core/surface/level-set-pass.js +291 -0
- package/dist/core/surface/level-set-pass.js.map +1 -0
- package/dist/core/surface/level-set-wgsl.d.ts +46 -0
- package/dist/core/surface/level-set-wgsl.js +99 -0
- package/dist/core/surface/level-set-wgsl.js.map +1 -0
- package/dist/core/surface/points.d.ts +109 -0
- package/dist/core/surface/points.js +226 -0
- package/dist/core/surface/points.js.map +1 -0
- package/dist/core/types.d.ts +37 -0
- package/dist/core/types.js +32 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/wgsl/api.d.ts +65 -0
- package/dist/core/wgsl/api.js +546 -0
- package/dist/core/wgsl/api.js.map +1 -0
- package/dist/core/wgsl/generate.d.ts +90 -0
- package/dist/core/wgsl/generate.js +678 -0
- package/dist/core/wgsl/generate.js.map +1 -0
- package/dist/core/wgsl/lean.d.ts +50 -0
- package/dist/core/wgsl/lean.js +327 -0
- package/dist/core/wgsl/lean.js.map +1 -0
- package/dist/core/wgsl/level-set.d.ts +58 -0
- package/dist/core/wgsl/level-set.js +200 -0
- package/dist/core/wgsl/level-set.js.map +1 -0
- package/dist/core/wgsl/majorant.d.ts +62 -0
- package/dist/core/wgsl/majorant.js +381 -0
- package/dist/core/wgsl/majorant.js.map +1 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.js +333 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
- package/dist/core/wgsl/reserved.d.ts +9 -0
- package/dist/core/wgsl/reserved.js +26 -0
- package/dist/core/wgsl/reserved.js.map +1 -0
- package/dist/core/wgsl/types.d.ts +198 -0
- package/dist/core/wgsl/types.js +2 -0
- package/dist/core/wgsl/types.js.map +1 -0
- package/dist/three/coarse-first.d.ts +207 -0
- package/dist/three/coarse-first.js +205 -0
- package/dist/three/coarse-first.js.map +1 -0
- package/dist/three/compute.d.ts +73 -0
- package/dist/three/compute.js +66 -0
- package/dist/three/compute.js.map +1 -0
- package/dist/three/device.d.ts +66 -0
- package/dist/three/device.js +62 -0
- package/dist/three/device.js.map +1 -0
- package/dist/three/frame/core-environment.d.ts +38 -0
- package/dist/three/frame/core-environment.js +154 -0
- package/dist/three/frame/core-environment.js.map +1 -0
- package/dist/three/frame/core-integrate-material.d.ts +34 -0
- package/dist/three/frame/core-integrate-material.js +162 -0
- package/dist/three/frame/core-integrate-material.js.map +1 -0
- package/dist/three/frame/core-occluders.d.ts +53 -0
- package/dist/three/frame/core-occluders.js +193 -0
- package/dist/three/frame/core-occluders.js.map +1 -0
- package/dist/three/frame/core-structs.d.ts +34 -0
- package/dist/three/frame/core-structs.js +61 -0
- package/dist/three/frame/core-structs.js.map +1 -0
- package/dist/three/frame/core-textures.d.ts +41 -0
- package/dist/three/frame/core-textures.js +114 -0
- package/dist/three/frame/core-textures.js.map +1 -0
- package/dist/three/frame/emission-light.d.ts +117 -0
- package/dist/three/frame/emission-light.js +276 -0
- package/dist/three/frame/emission-light.js.map +1 -0
- package/dist/three/frame/index.d.ts +19 -0
- package/dist/three/frame/index.js +15 -0
- package/dist/three/frame/index.js.map +1 -0
- package/dist/three/frame/medium.d.ts +33 -0
- package/dist/three/frame/medium.js +29 -0
- package/dist/three/frame/medium.js.map +1 -0
- package/dist/three/frame/renderer.d.ts +97 -0
- package/dist/three/frame/renderer.js +480 -0
- package/dist/three/frame/renderer.js.map +1 -0
- package/dist/three/frame/spectrum.d.ts +4 -0
- package/dist/three/frame/spectrum.js +15 -0
- package/dist/three/frame/spectrum.js.map +1 -0
- package/dist/three/frame/three-internals.d.ts +60 -0
- package/dist/three/frame/three-internals.js +152 -0
- package/dist/three/frame/three-internals.js.map +1 -0
- package/dist/three/frame/volume-shadows.d.ts +139 -0
- package/dist/three/frame/volume-shadows.js +403 -0
- package/dist/three/frame/volume-shadows.js.map +1 -0
- package/dist/three/frame/volume.d.ts +230 -0
- package/dist/three/frame/volume.js +268 -0
- package/dist/three/frame/volume.js.map +1 -0
- package/dist/three/grid-node.d.ts +229 -0
- package/dist/three/grid-node.js +545 -0
- package/dist/three/grid-node.js.map +1 -0
- package/dist/three/index.d.ts +52 -0
- package/dist/three/index.js +58 -0
- package/dist/three/index.js.map +1 -0
- package/dist/three/internal.d.ts +20 -0
- package/dist/three/internal.js +18 -0
- package/dist/three/internal.js.map +1 -0
- package/dist/three/level-set-material.d.ts +185 -0
- package/dist/three/level-set-material.js +241 -0
- package/dist/three/level-set-material.js.map +1 -0
- package/dist/three/level-set-physical-material.d.ts +154 -0
- package/dist/three/level-set-physical-material.js +253 -0
- package/dist/three/level-set-physical-material.js.map +1 -0
- package/dist/three/level-set-velocity.d.ts +94 -0
- package/dist/three/level-set-velocity.js +208 -0
- package/dist/three/level-set-velocity.js.map +1 -0
- package/dist/three/material.d.ts +324 -0
- package/dist/three/material.js +502 -0
- package/dist/three/material.js.map +1 -0
- package/dist/three/points.d.ts +140 -0
- package/dist/three/points.js +261 -0
- package/dist/three/points.js.map +1 -0
- package/dist/three/sparse-source.d.ts +165 -0
- package/dist/three/sparse-source.js +405 -0
- package/dist/three/sparse-source.js.map +1 -0
- package/dist/three/volume-source.d.ts +22 -0
- package/dist/three/volume-source.js +110 -0
- package/dist/three/volume-source.js.map +1 -0
- package/dist/tools/cpu/brick-atlas.d.ts +36 -0
- package/dist/tools/cpu/brick-atlas.js +129 -0
- package/dist/tools/cpu/brick-atlas.js.map +1 -0
- package/dist/tools/cpu/compute.d.ts +116 -0
- package/dist/tools/cpu/compute.js +239 -0
- package/dist/tools/cpu/compute.js.map +1 -0
- package/dist/tools/cpu/lean-reads.d.ts +81 -0
- package/dist/tools/cpu/lean-reads.js +262 -0
- package/dist/tools/cpu/lean-reads.js.map +1 -0
- package/dist/tools/cpu/level-set.d.ts +111 -0
- package/dist/tools/cpu/level-set.js +313 -0
- package/dist/tools/cpu/level-set.js.map +1 -0
- package/dist/tools/cpu/majorant.d.ts +265 -0
- package/dist/tools/cpu/majorant.js +541 -0
- package/dist/tools/cpu/majorant.js.map +1 -0
- package/dist/tools/cpu/march.d.ts +297 -0
- package/dist/tools/cpu/march.js +726 -0
- package/dist/tools/cpu/march.js.map +1 -0
- package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
- package/dist/tools/cpu/mesh-decimate.js +1225 -0
- package/dist/tools/cpu/mesh-decimate.js.map +1 -0
- package/dist/tools/cpu/points.d.ts +29 -0
- package/dist/tools/cpu/points.js +38 -0
- package/dist/tools/cpu/points.js.map +1 -0
- package/dist/tools/cpu/probe-coords.d.ts +70 -0
- package/dist/tools/cpu/probe-coords.js +116 -0
- package/dist/tools/cpu/probe-coords.js.map +1 -0
- package/dist/tools/cpu/read-value.d.ts +44 -0
- package/dist/tools/cpu/read-value.js +351 -0
- package/dist/tools/cpu/read-value.js.map +1 -0
- package/dist/tools/cpu/sample-trilinear.d.ts +43 -0
- package/dist/tools/cpu/sample-trilinear.js +168 -0
- package/dist/tools/cpu/sample-trilinear.js.map +1 -0
- package/dist/tools/cpu/stride-tables.d.ts +56 -0
- package/dist/tools/cpu/stride-tables.generated.d.ts +1059 -0
- package/dist/tools/cpu/stride-tables.generated.js +1267 -0
- package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
- package/dist/tools/cpu/stride-tables.js +78 -0
- package/dist/tools/cpu/stride-tables.js.map +1 -0
- package/dist/tools/cpu/surface-nets.d.ts +90 -0
- package/dist/tools/cpu/surface-nets.js +597 -0
- package/dist/tools/cpu/surface-nets.js.map +1 -0
- package/dist/tools/errors.d.ts +66 -0
- package/dist/tools/errors.js +67 -0
- package/dist/tools/errors.js.map +1 -0
- package/dist/tools/frame/ambient.d.ts +98 -0
- package/dist/tools/frame/ambient.js +274 -0
- package/dist/tools/frame/ambient.js.map +1 -0
- package/dist/tools/frame/blackbody.d.ts +57 -0
- package/dist/tools/frame/blackbody.js +151 -0
- package/dist/tools/frame/blackbody.js.map +1 -0
- package/dist/tools/frame/brick-cache.d.ts +165 -0
- package/dist/tools/frame/brick-cache.js +326 -0
- package/dist/tools/frame/brick-cache.js.map +1 -0
- package/dist/tools/frame/emission.d.ts +137 -0
- package/dist/tools/frame/emission.js +290 -0
- package/dist/tools/frame/emission.js.map +1 -0
- package/dist/tools/frame/environment-gpu.d.ts +111 -0
- package/dist/tools/frame/environment-gpu.js +280 -0
- package/dist/tools/frame/environment-gpu.js.map +1 -0
- package/dist/tools/frame/environment.d.ts +106 -0
- package/dist/tools/frame/environment.js +272 -0
- package/dist/tools/frame/environment.js.map +1 -0
- package/dist/tools/frame/froxel.d.ts +58 -0
- package/dist/tools/frame/froxel.js +115 -0
- package/dist/tools/frame/froxel.js.map +1 -0
- package/dist/tools/frame/grid.d.ts +392 -0
- package/dist/tools/frame/grid.js +802 -0
- package/dist/tools/frame/grid.js.map +1 -0
- package/dist/tools/frame/index.d.ts +150 -0
- package/dist/tools/frame/index.js +389 -0
- package/dist/tools/frame/index.js.map +1 -0
- package/dist/tools/frame/medium.d.ts +77 -0
- package/dist/tools/frame/medium.js +101 -0
- package/dist/tools/frame/medium.js.map +1 -0
- package/dist/tools/frame/mie-table.d.ts +6 -0
- package/dist/tools/frame/mie-table.js +16 -0
- package/dist/tools/frame/mie-table.js.map +1 -0
- package/dist/tools/frame/mie.d.ts +63 -0
- package/dist/tools/frame/mie.js +194 -0
- package/dist/tools/frame/mie.js.map +1 -0
- package/dist/tools/frame/mlp-nn.d.ts +36 -0
- package/dist/tools/frame/mlp-nn.js +159 -0
- package/dist/tools/frame/mlp-nn.js.map +1 -0
- package/dist/tools/frame/mlp-tza.d.ts +29 -0
- package/dist/tools/frame/mlp-tza.js +186 -0
- package/dist/tools/frame/mlp-tza.js.map +1 -0
- package/dist/tools/frame/mlp.d.ts +183 -0
- package/dist/tools/frame/mlp.js +434 -0
- package/dist/tools/frame/mlp.js.map +1 -0
- package/dist/tools/frame/ms-exit.d.ts +42 -0
- package/dist/tools/frame/ms-exit.js +90 -0
- package/dist/tools/frame/ms-exit.js.map +1 -0
- package/dist/tools/frame/multi-scale.d.ts +152 -0
- package/dist/tools/frame/multi-scale.js +302 -0
- package/dist/tools/frame/multi-scale.js.map +1 -0
- package/dist/tools/frame/neural-weights.d.ts +10 -0
- package/dist/tools/frame/neural-weights.js +244 -0
- package/dist/tools/frame/neural-weights.js.map +1 -0
- package/dist/tools/frame/neural.d.ts +80 -0
- package/dist/tools/frame/neural.js +150 -0
- package/dist/tools/frame/neural.js.map +1 -0
- package/dist/tools/frame/occluders.d.ts +51 -0
- package/dist/tools/frame/occluders.js +72 -0
- package/dist/tools/frame/occluders.js.map +1 -0
- package/dist/tools/frame/pyramid-layout.d.ts +55 -0
- package/dist/tools/frame/pyramid-layout.js +100 -0
- package/dist/tools/frame/pyramid-layout.js.map +1 -0
- package/dist/tools/frame/shadows.d.ts +190 -0
- package/dist/tools/frame/shadows.js +468 -0
- package/dist/tools/frame/shadows.js.map +1 -0
- package/dist/tools/frame/sparse.d.ts +147 -0
- package/dist/tools/frame/sparse.js +432 -0
- package/dist/tools/frame/sparse.js.map +1 -0
- package/dist/tools/frame/spectral-stack.d.ts +159 -0
- package/dist/tools/frame/spectral-stack.js +391 -0
- package/dist/tools/frame/spectral-stack.js.map +1 -0
- package/dist/tools/frame/spectral.d.ts +222 -0
- package/dist/tools/frame/spectral.js +572 -0
- package/dist/tools/frame/spectral.js.map +1 -0
- package/dist/tools/frame/stack.d.ts +115 -0
- package/dist/tools/frame/stack.js +290 -0
- package/dist/tools/frame/stack.js.map +1 -0
- package/dist/tools/frame/view.d.ts +131 -0
- package/dist/tools/frame/view.js +337 -0
- package/dist/tools/frame/view.js.map +1 -0
- package/dist/tools/index.d.ts +157 -0
- package/dist/tools/index.js +132 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/internal.d.ts +87 -0
- package/dist/tools/internal.js +85 -0
- package/dist/tools/internal.js.map +1 -0
- package/dist/tools/nanovdb/build-from-vdb.d.ts +59 -0
- package/dist/tools/nanovdb/build-from-vdb.js +100 -0
- package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
- package/dist/tools/nanovdb/bytes.d.ts +233 -0
- package/dist/tools/nanovdb/bytes.js +388 -0
- package/dist/tools/nanovdb/bytes.js.map +1 -0
- package/dist/tools/nanovdb/coarse-first.d.ts +78 -0
- package/dist/tools/nanovdb/coarse-first.js +92 -0
- package/dist/tools/nanovdb/coarse-first.js.map +1 -0
- package/dist/tools/nanovdb/half.d.ts +22 -0
- package/dist/tools/nanovdb/half.js +73 -0
- package/dist/tools/nanovdb/half.js.map +1 -0
- package/dist/tools/nanovdb/index.d.ts +34 -0
- package/dist/tools/nanovdb/index.js +25 -0
- package/dist/tools/nanovdb/index.js.map +1 -0
- package/dist/tools/nanovdb/inspect.d.ts +33 -0
- package/dist/tools/nanovdb/inspect.js +70 -0
- package/dist/tools/nanovdb/inspect.js.map +1 -0
- package/dist/tools/nanovdb/leaf-codec.d.ts +119 -0
- package/dist/tools/nanovdb/leaf-codec.js +356 -0
- package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
- package/dist/tools/nanovdb/quantize.d.ts +72 -0
- package/dist/tools/nanovdb/quantize.js +329 -0
- package/dist/tools/nanovdb/quantize.js.map +1 -0
- package/dist/tools/nanovdb/resample.d.ts +177 -0
- package/dist/tools/nanovdb/resample.js +692 -0
- package/dist/tools/nanovdb/resample.js.map +1 -0
- package/dist/tools/nanovdb/serialize.d.ts +176 -0
- package/dist/tools/nanovdb/serialize.js +439 -0
- package/dist/tools/nanovdb/serialize.js.map +1 -0
- package/dist/tools/nanovdb/stats.d.ts +87 -0
- package/dist/tools/nanovdb/stats.js +225 -0
- package/dist/tools/nanovdb/stats.js.map +1 -0
- package/dist/tools/nanovdb/transform.d.ts +30 -0
- package/dist/tools/nanovdb/transform.js +94 -0
- package/dist/tools/nanovdb/transform.js.map +1 -0
- package/dist/tools/nanovdb/tree.d.ts +186 -0
- package/dist/tools/nanovdb/tree.js +530 -0
- package/dist/tools/nanovdb/tree.js.map +1 -0
- package/dist/tools/nanovdb/write-nvdb.d.ts +74 -0
- package/dist/tools/nanovdb/write-nvdb.js +290 -0
- package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
- package/dist/tools/nvdb-file.d.ts +265 -0
- package/dist/tools/nvdb-file.js +763 -0
- package/dist/tools/nvdb-file.js.map +1 -0
- package/dist/tools/nvdb-stream.d.ts +154 -0
- package/dist/tools/nvdb-stream.js +409 -0
- package/dist/tools/nvdb-stream.js.map +1 -0
- package/dist/tools/reference/analytic.d.ts +41 -0
- package/dist/tools/reference/analytic.js +95 -0
- package/dist/tools/reference/analytic.js.map +1 -0
- package/dist/tools/reference/environment.d.ts +62 -0
- package/dist/tools/reference/environment.js +154 -0
- package/dist/tools/reference/environment.js.map +1 -0
- package/dist/tools/reference/index.d.ts +12 -0
- package/dist/tools/reference/index.js +13 -0
- package/dist/tools/reference/index.js.map +1 -0
- package/dist/tools/reference/media.d.ts +14 -0
- package/dist/tools/reference/media.js +30 -0
- package/dist/tools/reference/media.js.map +1 -0
- package/dist/tools/reference/rng.d.ts +20 -0
- package/dist/tools/reference/rng.js +30 -0
- package/dist/tools/reference/rng.js.map +1 -0
- package/dist/tools/reference/scene.d.ts +312 -0
- package/dist/tools/reference/scene.js +169 -0
- package/dist/tools/reference/scene.js.map +1 -0
- package/dist/tools/reference/tables.d.ts +98 -0
- package/dist/tools/reference/tables.js +264 -0
- package/dist/tools/reference/tables.js.map +1 -0
- package/dist/tools/reference/trace.d.ts +160 -0
- package/dist/tools/reference/trace.js +497 -0
- package/dist/tools/reference/trace.js.map +1 -0
- package/dist/tools/vdb/bit-utils.d.ts +20 -0
- package/dist/tools/vdb/bit-utils.js +42 -0
- package/dist/tools/vdb/bit-utils.js.map +1 -0
- package/dist/tools/vdb/blosc-write.d.ts +43 -0
- package/dist/tools/vdb/blosc-write.js +197 -0
- package/dist/tools/vdb/blosc-write.js.map +1 -0
- package/dist/tools/vdb/blosc.d.ts +86 -0
- package/dist/tools/vdb/blosc.js +287 -0
- package/dist/tools/vdb/blosc.js.map +1 -0
- package/dist/tools/vdb/blosclz.d.ts +33 -0
- package/dist/tools/vdb/blosclz.js +112 -0
- package/dist/tools/vdb/blosclz.js.map +1 -0
- package/dist/tools/vdb/byte-reader.d.ts +50 -0
- package/dist/tools/vdb/byte-reader.js +161 -0
- package/dist/tools/vdb/byte-reader.js.map +1 -0
- package/dist/tools/vdb/compression.d.ts +81 -0
- package/dist/tools/vdb/compression.js +260 -0
- package/dist/tools/vdb/compression.js.map +1 -0
- package/dist/tools/vdb/errors.d.ts +10 -0
- package/dist/tools/vdb/errors.js +11 -0
- package/dist/tools/vdb/errors.js.map +1 -0
- package/dist/tools/vdb/grid.d.ts +37 -0
- package/dist/tools/vdb/grid.js +153 -0
- package/dist/tools/vdb/grid.js.map +1 -0
- package/dist/tools/vdb/half-float.d.ts +9 -0
- package/dist/tools/vdb/half-float.js +24 -0
- package/dist/tools/vdb/half-float.js.map +1 -0
- package/dist/tools/vdb/index.d.ts +4 -0
- package/dist/tools/vdb/index.js +3 -0
- package/dist/tools/vdb/index.js.map +1 -0
- package/dist/tools/vdb/inflate.d.ts +24 -0
- package/dist/tools/vdb/inflate.js +334 -0
- package/dist/tools/vdb/inflate.js.map +1 -0
- package/dist/tools/vdb/lz4.d.ts +30 -0
- package/dist/tools/vdb/lz4.js +228 -0
- package/dist/tools/vdb/lz4.js.map +1 -0
- package/dist/tools/vdb/metadata.d.ts +17 -0
- package/dist/tools/vdb/metadata.js +72 -0
- package/dist/tools/vdb/metadata.js.map +1 -0
- package/dist/tools/vdb/parse.d.ts +47 -0
- package/dist/tools/vdb/parse.js +241 -0
- package/dist/tools/vdb/parse.js.map +1 -0
- package/dist/tools/vdb/point-render-data.d.ts +79 -0
- package/dist/tools/vdb/point-render-data.js +137 -0
- package/dist/tools/vdb/point-render-data.js.map +1 -0
- package/dist/tools/vdb/points.d.ts +186 -0
- package/dist/tools/vdb/points.js +835 -0
- package/dist/tools/vdb/points.js.map +1 -0
- package/dist/tools/vdb/transform.d.ts +23 -0
- package/dist/tools/vdb/transform.js +54 -0
- package/dist/tools/vdb/transform.js.map +1 -0
- package/dist/tools/vdb/tree.d.ts +111 -0
- package/dist/tools/vdb/tree.js +228 -0
- package/dist/tools/vdb/tree.js.map +1 -0
- package/dist/tools/vdb/types.d.ts +195 -0
- package/dist/tools/vdb/types.js +3 -0
- package/dist/tools/vdb/types.js.map +1 -0
- package/dist/tools/wvdb/bake.d.ts +145 -0
- package/dist/tools/wvdb/bake.js +361 -0
- package/dist/tools/wvdb/bake.js.map +1 -0
- package/dist/tools/wvdb/dense.d.ts +191 -0
- package/dist/tools/wvdb/dense.js +368 -0
- package/dist/tools/wvdb/dense.js.map +1 -0
- package/dist/tools/wvdb/format.d.ts +220 -0
- package/dist/tools/wvdb/format.js +306 -0
- package/dist/tools/wvdb/format.js.map +1 -0
- package/dist/tools/wvdb/index.d.ts +14 -0
- package/dist/tools/wvdb/index.js +15 -0
- package/dist/tools/wvdb/index.js.map +1 -0
- package/dist/tools/wvdb/level-set.d.ts +56 -0
- package/dist/tools/wvdb/level-set.js +153 -0
- package/dist/tools/wvdb/level-set.js.map +1 -0
- package/dist/tools/wvdb/nanovdb.d.ts +59 -0
- package/dist/tools/wvdb/nanovdb.js +64 -0
- package/dist/tools/wvdb/nanovdb.js.map +1 -0
- package/dist/tools/wvdb/partial.d.ts +74 -0
- package/dist/tools/wvdb/partial.js +233 -0
- package/dist/tools/wvdb/partial.js.map +1 -0
- package/dist/tools/wvdb/read.d.ts +336 -0
- package/dist/tools/wvdb/read.js +766 -0
- package/dist/tools/wvdb/read.js.map +1 -0
- package/dist/tools/wvdb/sha256.d.ts +7 -0
- package/dist/tools/wvdb/sha256.js +76 -0
- package/dist/tools/wvdb/sha256.js.map +1 -0
- package/dist/tools/wvdb/write.d.ts +149 -0
- package/dist/tools/wvdb/write.js +403 -0
- package/dist/tools/wvdb/write.js.map +1 -0
- package/package.json +83 -4
- package/vendor/LICENSE +201 -0
- package/vendor/NOTICE +19 -0
- package/vendor/VENDOR.md +100 -0
- package/vendor/pnanovdb.wgsl +1577 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/wvdb/wvdbKernel.js (toByte, toTexels, writeBricks, background fill),
|
|
3
|
+
// src/three-openvdb/wvdb/WVDBReader.js (getBackgroundTexel, getScale, baked density stats),
|
|
4
|
+
// src/three-openvdb/wvdb/WVDBLoader.js (attach / updateTextures stats rules),
|
|
5
|
+
// src/three-openvdb/frame/core/FrameVolume.js (getDensityStats, getMeanDensity, getDensityScale),
|
|
6
|
+
// src/three-openvdb/frame/webgpu/frameMipmaps.js (box mip atlas: downsample, packAtlas),
|
|
7
|
+
// src/three-openvdb/frame/webgpu/frameShaderChunks.js (sampleMipAtlas, sampleMipmapped, getLod).
|
|
8
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
9
|
+
// Changes: TypeScript, works from our decoded `.wvdb` levels (read.ts) instead of his worker kernel;
|
|
10
|
+
// Gaussian mips not ported. Divergences: DIVERGES.md V23–V25.
|
|
11
|
+
/**
|
|
12
|
+
* The dense `.wvdb` volume source, CPU half (K3.0, R1 §4.2): the exact bytes
|
|
13
|
+
* mjurczyk's renderer uploads for a `.wvdb` grid, built from our decoded LODs.
|
|
14
|
+
*
|
|
15
|
+
* His path is `WVDBLoader` → `WVDBReader` → worker `wvdbKernel` (8-bit texels:
|
|
16
|
+
* `clamp(value / scale, 0, 1) * 255 | 0`, level sets 255 inside the band, vector
|
|
17
|
+
* grids RGBA8 with alpha 255) → `new FrameVolume(grid.data, { dimensions, bbox })`
|
|
18
|
+
* (an R8 `Data3DTexture`, linear filter, clamp to edge, no GPU mipmaps) plus a CPU
|
|
19
|
+
* box mip atlas (`frameMipmaps.js`: levels 1..n side by side on x). The engine-free
|
|
20
|
+
* GPU upload is `vdbDenseSource` in core; the three textures are `vdbDenseTextures`
|
|
21
|
+
* in `./three`. Both upload exactly these bytes (`test/tools/wvdb-dense.test.ts`
|
|
22
|
+
* checks them against a re-implementation of his upload path).
|
|
23
|
+
*
|
|
24
|
+
* Values are 8-bit and clamped to [0, 1] (R1 §4.3 `normalize: 'clamp01'`): a
|
|
25
|
+
* density above `scale` saturates, as in his renderer.
|
|
26
|
+
*/
|
|
27
|
+
import { VDBToolsError } from "../errors.js";
|
|
28
|
+
/** WVDBReader.js L128 / wvdbKernel.js L20: `(Math.min(Math.max(value, 0.0), 1.0) * 255.0) | 0`. */
|
|
29
|
+
export const wvdbToByte = (value) => (Math.min(Math.max(value, 0.0), 1.0) * 255.0) | 0;
|
|
30
|
+
/**
|
|
31
|
+
* The 8-bit texels his worker kernel produces for one decoded LOD (wvdbKernel.js
|
|
32
|
+
* `toTexels` L24–58, `writeBricks` L89–119 over a background fill L255–256 with
|
|
33
|
+
* `getBackgroundTexel` WVDBReader.js L131–137). Our decoded level already holds
|
|
34
|
+
* the background where no brick is stored, so the per-voxel rule is applied to
|
|
35
|
+
* the whole dense array. Scalar: 1 byte; vector: RGBA8 with alpha 255 (no scale).
|
|
36
|
+
*/
|
|
37
|
+
export function wvdbTexels(grid, level, scale = 1) {
|
|
38
|
+
const [w, h, d] = level.dimensions;
|
|
39
|
+
const plane = w * h * d;
|
|
40
|
+
const values = level.values;
|
|
41
|
+
if (level.channels === 3) {
|
|
42
|
+
const out = new Uint8Array(plane * 4);
|
|
43
|
+
for (let i = 0; i < plane; i++) {
|
|
44
|
+
out[i * 4] = wvdbToByte(values[i]);
|
|
45
|
+
out[i * 4 + 1] = wvdbToByte(values[plane + i]);
|
|
46
|
+
out[i * 4 + 2] = wvdbToByte(values[2 * plane + i]);
|
|
47
|
+
out[i * 4 + 3] = 255;
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
const out = new Uint8Array(plane);
|
|
52
|
+
if (grid.class === "level set") {
|
|
53
|
+
const background = grid.background[0];
|
|
54
|
+
for (let i = 0; i < plane; i++)
|
|
55
|
+
out[i] = Math.abs(values[i]) < background ? 255 : 0;
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
for (let i = 0; i < plane; i++)
|
|
59
|
+
out[i] = wvdbToByte(values[i] / scale);
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
/** FrameVolume.js L50–62 `getDensityStats`. */
|
|
63
|
+
export function wvdbTexelStats(data) {
|
|
64
|
+
let sum = 0;
|
|
65
|
+
let count = 0;
|
|
66
|
+
for (let i = 0; i < data.length; i++) {
|
|
67
|
+
if (data[i] > 0) {
|
|
68
|
+
sum += data[i];
|
|
69
|
+
count++;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { sum: sum / 255.0, count };
|
|
73
|
+
}
|
|
74
|
+
/** frameMipmaps.js L14 `getLevelSize` (ceil sizes; the WebGL path floors, R1 §8 quality note 5). */
|
|
75
|
+
export const wvdbMipLevelSize = (size, level) => Math.max(1, Math.ceil(size / 2 ** level));
|
|
76
|
+
/** frameMipmaps.js L16–17 `getMipLevelCount`. */
|
|
77
|
+
export const wvdbMipLevelCount = (width, height, depth) => Math.ceil(Math.log2(Math.max(width, height, depth, 1)));
|
|
78
|
+
/** frameMipmaps.js L20–62: 2x2x2 box mean, `Math.round(sum / 8)`, edge taps clamped. */
|
|
79
|
+
function downsample(source, width, height, depth, channels) {
|
|
80
|
+
const tw = wvdbMipLevelSize(width, 1);
|
|
81
|
+
const th = wvdbMipLevelSize(height, 1);
|
|
82
|
+
const td = wvdbMipLevelSize(depth, 1);
|
|
83
|
+
const target = new Uint8Array(tw * th * td * channels);
|
|
84
|
+
for (let z = 0; z < td; z++) {
|
|
85
|
+
const z0 = Math.min(z * 2, depth - 1);
|
|
86
|
+
const z1 = Math.min(z * 2 + 1, depth - 1);
|
|
87
|
+
for (let y = 0; y < th; y++) {
|
|
88
|
+
const y0 = Math.min(y * 2, height - 1);
|
|
89
|
+
const y1 = Math.min(y * 2 + 1, height - 1);
|
|
90
|
+
const row00 = (y0 + z0 * height) * width;
|
|
91
|
+
const row10 = (y1 + z0 * height) * width;
|
|
92
|
+
const row01 = (y0 + z1 * height) * width;
|
|
93
|
+
const row11 = (y1 + z1 * height) * width;
|
|
94
|
+
for (let x = 0; x < tw; x++) {
|
|
95
|
+
const x0 = Math.min(x * 2, width - 1);
|
|
96
|
+
const x1 = Math.min(x * 2 + 1, width - 1);
|
|
97
|
+
const t = (x + (y + z * th) * tw) * channels;
|
|
98
|
+
for (let c = 0; c < channels; c++) {
|
|
99
|
+
const sum = source[(x0 + row00) * channels + c] +
|
|
100
|
+
source[(x1 + row00) * channels + c] +
|
|
101
|
+
source[(x0 + row10) * channels + c] +
|
|
102
|
+
source[(x1 + row10) * channels + c] +
|
|
103
|
+
source[(x0 + row01) * channels + c] +
|
|
104
|
+
source[(x1 + row01) * channels + c] +
|
|
105
|
+
source[(x0 + row11) * channels + c] +
|
|
106
|
+
source[(x1 + row11) * channels + c];
|
|
107
|
+
target[t + c] = Math.round(sum / 8);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return { data: target, width: tw, height: th, depth: td };
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The mip atlas size and level count `wvdbMipAtlas` gives for a texture of `dimensions`, without building it
|
|
116
|
+
* (null when the texture has one texel on every side).
|
|
117
|
+
*/
|
|
118
|
+
export function wvdbMipAtlasLayout(dimensions) {
|
|
119
|
+
const [width, height, depth] = dimensions;
|
|
120
|
+
const levels = wvdbMipLevelCount(width, height, depth);
|
|
121
|
+
if (levels < 1)
|
|
122
|
+
return null;
|
|
123
|
+
return { dimensions: [2 ** Math.max(Math.ceil(Math.log2(width)), levels), wvdbMipLevelSize(height, 1), wvdbMipLevelSize(depth, 1)], levels };
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* frameMipmaps.js L90–106 `buildAtlas` + L65–88 `packAtlas`: levels 1..n (n =
|
|
127
|
+
* `ceil(log2(max side))`), level l at x = atlasWidth − atlasWidth / 2^(l−1);
|
|
128
|
+
* atlas width 2^max(ceil(log2 width), n), height and depth those of level 1.
|
|
129
|
+
* Null when the texture has one texel on every side.
|
|
130
|
+
*/
|
|
131
|
+
export function wvdbMipAtlas(data, dimensions, channels,
|
|
132
|
+
/** K4.22: edits level 1 (texels x fastest) before the higher levels are built from it. */
|
|
133
|
+
editLevel1) {
|
|
134
|
+
const [width, height, depth] = dimensions;
|
|
135
|
+
const count = wvdbMipLevelCount(width, height, depth);
|
|
136
|
+
if (count < 1)
|
|
137
|
+
return null;
|
|
138
|
+
const levels = [];
|
|
139
|
+
let level = { data, width, height, depth };
|
|
140
|
+
for (let index = 1; index <= count; index++) {
|
|
141
|
+
level = downsample(level.data, level.width, level.height, level.depth, channels);
|
|
142
|
+
if (index === 1)
|
|
143
|
+
editLevel1?.(level);
|
|
144
|
+
levels.push(level);
|
|
145
|
+
}
|
|
146
|
+
const atlasWidth = 2 ** Math.max(Math.ceil(Math.log2(width)), levels.length);
|
|
147
|
+
const atlasHeight = wvdbMipLevelSize(height, 1);
|
|
148
|
+
const atlasDepth = wvdbMipLevelSize(depth, 1);
|
|
149
|
+
const atlas = new Uint8Array(atlasWidth * atlasHeight * atlasDepth * channels);
|
|
150
|
+
levels.forEach((l, levelIndex) => {
|
|
151
|
+
const offset = atlasWidth - atlasWidth / 2 ** levelIndex;
|
|
152
|
+
for (let z = 0; z < l.depth; z++) {
|
|
153
|
+
for (let y = 0; y < l.height; y++) {
|
|
154
|
+
const sourceStart = (y + z * l.height) * l.width * channels;
|
|
155
|
+
const targetStart = (offset + (y + z * atlasHeight) * atlasWidth) * channels;
|
|
156
|
+
atlas.set(l.data.subarray(sourceStart, sourceStart + l.width * channels), targetStart);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
return { data: atlas, dimensions: [atlasWidth, atlasHeight, atlasDepth], levels: levels.length };
|
|
161
|
+
}
|
|
162
|
+
function denseTexture(data, dimensions, texelBytes, mipmaps) {
|
|
163
|
+
return {
|
|
164
|
+
data,
|
|
165
|
+
dimensions,
|
|
166
|
+
format: texelBytes === 4 ? "rgba8unorm" : "r8unorm",
|
|
167
|
+
texelBytes,
|
|
168
|
+
mip: mipmaps ? wvdbMipAtlas(data, dimensions, texelBytes) : null,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* K4.22: a texture whose `fill` bricks are still background. Its mip atlas is built on first read of `mip.data`
|
|
173
|
+
* (from the background-filled texels): the core's dense source builds the filled atlas on the GPU and never reads it.
|
|
174
|
+
*/
|
|
175
|
+
export function wvdbDenseFillTexture(data, dimensions, texelBytes, mipmaps, fill) {
|
|
176
|
+
if (!fill)
|
|
177
|
+
return denseTexture(data, dimensions, texelBytes, mipmaps);
|
|
178
|
+
const layout = mipmaps ? wvdbMipAtlasLayout(dimensions) : null;
|
|
179
|
+
let atlas = null;
|
|
180
|
+
const mip = layout
|
|
181
|
+
? {
|
|
182
|
+
get data() {
|
|
183
|
+
return (atlas ??= wvdbMipAtlas(data, dimensions, texelBytes).data);
|
|
184
|
+
},
|
|
185
|
+
dimensions: layout.dimensions,
|
|
186
|
+
levels: layout.levels,
|
|
187
|
+
}
|
|
188
|
+
: null;
|
|
189
|
+
return { data, dimensions, format: texelBytes === 4 ? "rgba8unorm" : "r8unorm", texelBytes, mip, fill };
|
|
190
|
+
}
|
|
191
|
+
function volumeGrid(file, name, role) {
|
|
192
|
+
const grid = file.grids.find((g) => g.name === name);
|
|
193
|
+
if (!grid)
|
|
194
|
+
throw new VDBToolsError("VDB_BAD_OPTION", `wvdbDenseVolume: no grid named "${name}" for ${role} (grids: ${file.grids.map((g) => g.name).join(", ")})`);
|
|
195
|
+
if (grid.kind !== "volume")
|
|
196
|
+
throw new VDBToolsError("VDB_BAD_OPTION", `wvdbDenseVolume: grid "${name}" (${role}) is a points grid; dense sources take volume grids`);
|
|
197
|
+
return grid;
|
|
198
|
+
}
|
|
199
|
+
function levelOf(grid, lod) {
|
|
200
|
+
const level = grid.levels[lod];
|
|
201
|
+
if (!level) {
|
|
202
|
+
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`);
|
|
203
|
+
}
|
|
204
|
+
return level;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Builds the dense textures his renderer would upload for one LOD of a decoded
|
|
208
|
+
* `.wvdb` file: density (R8), optional mask (R8), albedo (RGBA8) and emission
|
|
209
|
+
* (R8), each with its CPU box mip atlas, plus the density stats his volume uses
|
|
210
|
+
* for `normalizeDensity` (`meanDensity`).
|
|
211
|
+
* @param file A decoded `.wvdb` ({@link readWvdb}) with the LOD's levels.
|
|
212
|
+
* @param o Which grids to read, the LOD, scales and mipmaps.
|
|
213
|
+
*/
|
|
214
|
+
export function wvdbDenseVolume(file, o = {}) {
|
|
215
|
+
const density = wvdbDenseDensityGrid(file, o);
|
|
216
|
+
const lod = o.lod ?? density.levels.length - 1;
|
|
217
|
+
if (!Number.isInteger(lod) || lod < 0)
|
|
218
|
+
throw new VDBToolsError("VDB_BAD_OPTION", `wvdbDenseVolume: lod must be a non-negative integer, got ${o.lod}`);
|
|
219
|
+
return wvdbDenseAssemble(file, o, lod, { level: (grid) => levelOf(grid, lod) });
|
|
220
|
+
}
|
|
221
|
+
/** @internal The density grid {@link wvdbDenseVolume} reads (`o.density`, else `density`, else the first volume grid). */
|
|
222
|
+
export function wvdbDenseDensityGrid(file, o) {
|
|
223
|
+
const volumeGrids = file.grids.filter((g) => g.kind === "volume");
|
|
224
|
+
const densityName = o.density ?? (file.grids.find((g) => g.name === "density" && g.kind === "volume") ?? volumeGrids[0])?.name;
|
|
225
|
+
if (densityName === undefined)
|
|
226
|
+
throw new VDBToolsError("VDB_BAD_OPTION", "wvdbDenseVolume: the file has no volume grid");
|
|
227
|
+
const density = volumeGrid(file, densityName, "density");
|
|
228
|
+
if (density.channels !== 1)
|
|
229
|
+
throw new VDBToolsError("VDB_BAD_OPTION", `wvdbDenseVolume: density grid "${densityName}" has 3 channels; pass a scalar grid`);
|
|
230
|
+
return density;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* @internal {@link wvdbDenseVolume}'s assembly from one level per grid (`how.level`): texels, aux channels, stats.
|
|
234
|
+
* K4.22's partial volumes pass the stream event's levels and textures with a `fill`.
|
|
235
|
+
*/
|
|
236
|
+
export function wvdbDenseAssemble(file, o, lod, how) {
|
|
237
|
+
const density = wvdbDenseDensityGrid(file, o);
|
|
238
|
+
const densityName = density.name;
|
|
239
|
+
const mipmaps = o.mipmaps ?? true;
|
|
240
|
+
// WVDBReader.js L494: scales[name] || 1.0
|
|
241
|
+
const scaleOf = (name) => o.scales?.[name] || 1.0;
|
|
242
|
+
const level = how.level(density, "density");
|
|
243
|
+
const dimensions = [...level.dimensions];
|
|
244
|
+
const densityData = wvdbTexels(density, level, scaleOf(densityName));
|
|
245
|
+
const makeTexture = (grid, l, data, texelBytes) => how.texture ? how.texture(grid, l, data, texelBytes, mipmaps, scaleOf(grid.name)) : denseTexture(data, dimensions, texelBytes, mipmaps);
|
|
246
|
+
const aux = (name, role) => {
|
|
247
|
+
if (name === undefined)
|
|
248
|
+
return null;
|
|
249
|
+
const grid = volumeGrid(file, name, role);
|
|
250
|
+
const want = role === "albedo" ? 3 : 1;
|
|
251
|
+
if (grid.channels !== want)
|
|
252
|
+
throw new VDBToolsError("VDB_BAD_OPTION", `wvdbDenseVolume: ${role} grid "${name}" has ${grid.channels} channel(s), expected ${want}`);
|
|
253
|
+
const auxLevel = how.level(grid, role);
|
|
254
|
+
if (auxLevel.dimensions.some((v, a) => v !== dimensions[a])) {
|
|
255
|
+
// FrameVolume.js L357–405: raw aux grids are uploaded at the density grid's dimensions.
|
|
256
|
+
throw new VDBToolsError("VDB_BAD_OPTION", `wvdbDenseVolume: ${role} grid "${name}" LOD ${lod} is ${auxLevel.dimensions.join("x")}, density is ${dimensions.join("x")}; ` +
|
|
257
|
+
"his renderer uploads aux grids at the density size, so they must match");
|
|
258
|
+
}
|
|
259
|
+
const data = wvdbTexels(grid, auxLevel, scaleOf(name));
|
|
260
|
+
return makeTexture(grid, auxLevel, data, role === "albedo" ? 4 : 1);
|
|
261
|
+
};
|
|
262
|
+
// WVDBReader.js L519–523 + WVDBLoader.js L147–152: baked stats when the header has
|
|
263
|
+
// meanDensity and the scale is 1; else WVDBLoader.js L196–198 getDensityStats(data).
|
|
264
|
+
const baked = typeof density.meanDensity === "number" && scaleOf(densityName) === 1.0;
|
|
265
|
+
const densityStats = baked
|
|
266
|
+
? { sum: density.meanDensity * density.nonZeroVoxels, count: density.nonZeroVoxels }
|
|
267
|
+
: wvdbTexelStats(densityData);
|
|
268
|
+
let max = 0;
|
|
269
|
+
let active = 0;
|
|
270
|
+
for (let i = 0; i < densityData.length; i++) {
|
|
271
|
+
const v = densityData[i];
|
|
272
|
+
if (v > max)
|
|
273
|
+
max = v;
|
|
274
|
+
if (v > 0)
|
|
275
|
+
active++;
|
|
276
|
+
}
|
|
277
|
+
const densityTexture = makeTexture(density, level, densityData, 1);
|
|
278
|
+
// K4.22: upsampled texels lie between coarse texels, so the coarse LOD's largest bounds them (vdbSrcMaxIn).
|
|
279
|
+
const from = densityTexture.fill?.from.data;
|
|
280
|
+
if (from)
|
|
281
|
+
for (let i = 0; i < from.length; i++)
|
|
282
|
+
if (from[i] > max)
|
|
283
|
+
max = from[i];
|
|
284
|
+
return {
|
|
285
|
+
kind: "dense",
|
|
286
|
+
normalize: "clamp01",
|
|
287
|
+
lod,
|
|
288
|
+
dimensions,
|
|
289
|
+
bbox: density.bbox,
|
|
290
|
+
density: densityTexture,
|
|
291
|
+
mask: aux(o.mask, "mask"),
|
|
292
|
+
albedo: aux(o.albedo, "albedo"),
|
|
293
|
+
emission: aux(o.emission, "emission"),
|
|
294
|
+
densityStats,
|
|
295
|
+
densityStatsSource: baked ? "baked" : "texels",
|
|
296
|
+
// FrameVolume.js L65–75 getMeanDensity (one volume)
|
|
297
|
+
meanDensity: densityStats.count > 0 ? densityStats.sum / densityStats.count : 0.0,
|
|
298
|
+
maxDensity: max / 255,
|
|
299
|
+
activeTexels: active,
|
|
300
|
+
gridNames: {
|
|
301
|
+
density: densityName,
|
|
302
|
+
...(o.mask !== undefined ? { mask: o.mask } : {}),
|
|
303
|
+
...(o.albedo !== undefined ? { albedo: o.albedo } : {}),
|
|
304
|
+
...(o.emission !== undefined ? { emission: o.emission } : {}),
|
|
305
|
+
},
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/** FrameVolume.js L561–568 `getDensityScale`: `densityScale / meanDensity` with `normalizeDensity`. */
|
|
309
|
+
export function wvdbDensityScale(volume, densityScale = 1.0, normalizeDensity = true) {
|
|
310
|
+
return normalizeDensity && volume.meanDensity > 0.0 ? densityScale / volume.meanDensity : densityScale;
|
|
311
|
+
}
|
|
312
|
+
// ---------------------------------------------------------------------------
|
|
313
|
+
// CPU twin of the dense source's sampling (vdbSrcDensity & co. in core)
|
|
314
|
+
// ---------------------------------------------------------------------------
|
|
315
|
+
/** Linear filtering, clamp to edge, of one channel at uvw in [0, 1]³ (texel centres at (i + 0.5) / size). */
|
|
316
|
+
function linear(data, dims, texelBytes, channel, u, v, w) {
|
|
317
|
+
// dims: the sampled texture's size (for the mip atlas, the whole atlas: its taps clamp at the atlas edge, not the level's).
|
|
318
|
+
const [W, H, D] = dims;
|
|
319
|
+
const fx = u * W - 0.5;
|
|
320
|
+
const fy = v * H - 0.5;
|
|
321
|
+
const fz = w * D - 0.5;
|
|
322
|
+
const x0 = Math.floor(fx);
|
|
323
|
+
const y0 = Math.floor(fy);
|
|
324
|
+
const z0 = Math.floor(fz);
|
|
325
|
+
const tx = fx - x0;
|
|
326
|
+
const ty = fy - y0;
|
|
327
|
+
const tz = fz - z0;
|
|
328
|
+
const cl = (i, n) => Math.min(Math.max(i, 0), n - 1);
|
|
329
|
+
const at = (x, y, z) => data[(cl(x, W) + (cl(y, H) + cl(z, D) * H) * W) * texelBytes + channel] / 255;
|
|
330
|
+
const c00 = at(x0, y0, z0) * (1 - tx) + at(x0 + 1, y0, z0) * tx;
|
|
331
|
+
const c10 = at(x0, y0 + 1, z0) * (1 - tx) + at(x0 + 1, y0 + 1, z0) * tx;
|
|
332
|
+
const c01 = at(x0, y0, z0 + 1) * (1 - tx) + at(x0 + 1, y0, z0 + 1) * tx;
|
|
333
|
+
const c11 = at(x0, y0 + 1, z0 + 1) * (1 - tx) + at(x0 + 1, y0 + 1, z0 + 1) * tx;
|
|
334
|
+
const c0 = c00 * (1 - ty) + c10 * ty;
|
|
335
|
+
const c1 = c01 * (1 - ty) + c11 * ty;
|
|
336
|
+
return c0 * (1 - tz) + c1 * tz;
|
|
337
|
+
}
|
|
338
|
+
/** frameShaderChunks.js L838–846 `sampleMipAtlas` (level ≥ 1). */
|
|
339
|
+
function sampleMipAtlasCpu(tex, level, uvw, channel) {
|
|
340
|
+
const atlas = tex.mip;
|
|
341
|
+
const [AW, AH, AD] = atlas.dimensions;
|
|
342
|
+
const size = tex.dimensions.map((t) => Math.max(1, Math.ceil(t / 2 ** level)));
|
|
343
|
+
const offset = AW - AW / 2 ** (level - 1);
|
|
344
|
+
const texel = uvw.map((c, a) => Math.min(Math.max(c * size[a], 0.5), size[a] - 0.5));
|
|
345
|
+
return linear(atlas.data, [AW, AH, AD], tex.texelBytes, channel, (texel[0] + offset) / AW, texel[1] / AH, texel[2] / AD);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* CPU twin of the dense source's read at `uvw` (already offset and wrapped) and
|
|
349
|
+
* `lod` (frameShaderChunks.js L849–877 `sampleMipmapped` / `sample3D`): hardware
|
|
350
|
+
* trilinear on the 8-bit texels (as normalized floats), and with mip levels a
|
|
351
|
+
* linear blend of the two nearest levels from the atlas. Real GPUs filter with
|
|
352
|
+
* limited weight precision (typically 8 fractional bits), so compare with a
|
|
353
|
+
* tolerance of about 1/255 of the local value range.
|
|
354
|
+
*/
|
|
355
|
+
export function sampleWvdbDenseTexture(tex, uvw, lod = 0, channel = 0) {
|
|
356
|
+
const levels = tex.mip?.levels ?? 0;
|
|
357
|
+
const base = () => linear(tex.data, tex.dimensions, tex.texelBytes, channel, uvw[0], uvw[1], uvw[2]);
|
|
358
|
+
if (levels === 0)
|
|
359
|
+
return base();
|
|
360
|
+
const level = Math.min(lod, levels);
|
|
361
|
+
if (level <= 0)
|
|
362
|
+
return base();
|
|
363
|
+
const level0 = Math.floor(level);
|
|
364
|
+
const low = level0 < 0.5 ? base() : sampleMipAtlasCpu(tex, level0, uvw, channel);
|
|
365
|
+
const high = sampleMipAtlasCpu(tex, Math.min(level0 + 1, levels), uvw, channel);
|
|
366
|
+
return low + (high - low) * (level - level0);
|
|
367
|
+
}
|
|
368
|
+
//# sourceMappingURL=dense.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,GAA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AAE,CAAC,CAAC;IACxG,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,EAAE,CAAC;IAChC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,IAAI,EAAE,CAAC;IAC9B,MAAM,MAAM,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"]}
|