@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,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the few NanoVDB `GridData` / `TreeData` / `RootData` fields a pool record
|
|
3
|
+
* needs, by byte offset (docs/dev/design/K1-core.md §1.4). The core never imports
|
|
4
|
+
* `tools` (D20), so the offsets are restated here; `test/core/image-header.test.ts`
|
|
5
|
+
* cross-checks every one against `tools`' constants and `vendor/stride-tables.json`
|
|
6
|
+
* (ABI 32.11.0, PNanoVDB.h; the offsets are those of 32.9.1).
|
|
7
|
+
*/
|
|
8
|
+
import { VDBError } from "../errors.js";
|
|
9
|
+
import { halfBitsToNumber } from "../half.js";
|
|
10
|
+
import { VDB_GRID_TYPE_IDS } from "../types.js";
|
|
11
|
+
/** Byte offsets inside a NanoVDB grid image used by the pool. */
|
|
12
|
+
export const NANOVDB_OFFSETS = {
|
|
13
|
+
/** `GridData` size; `TreeData` follows it. */
|
|
14
|
+
gridSize: 672,
|
|
15
|
+
gridMagic: 0,
|
|
16
|
+
gridVersion: 16,
|
|
17
|
+
gridFlags: 20,
|
|
18
|
+
/** u64 `mGridSize`. */
|
|
19
|
+
gridByteSize: 32,
|
|
20
|
+
gridName: 40,
|
|
21
|
+
gridNameMax: 256,
|
|
22
|
+
gridMap: 296,
|
|
23
|
+
mapMatD: 88,
|
|
24
|
+
mapInvMatD: 160,
|
|
25
|
+
mapVecD: 232,
|
|
26
|
+
gridWorldBBox: 560,
|
|
27
|
+
gridVoxelSize: 608,
|
|
28
|
+
gridClass: 632,
|
|
29
|
+
gridType: 636,
|
|
30
|
+
treeSize: 64,
|
|
31
|
+
/** u64, relative to `TreeData`. */
|
|
32
|
+
treeNodeOffsetRoot: 24,
|
|
33
|
+
rootBBoxMin: 0,
|
|
34
|
+
rootBBoxMax: 12,
|
|
35
|
+
/** `RootData` base size before the typed background/stats. */
|
|
36
|
+
rootBaseSize: 28,
|
|
37
|
+
/** Typed root fields for Float/Fp4/Fp8/Fp16/FpN (all store f32 here). */
|
|
38
|
+
rootBackground: 28,
|
|
39
|
+
rootMin: 32,
|
|
40
|
+
rootMax: 36,
|
|
41
|
+
/** The average statistic is f32 for every scalar type: after min / max (f32: 40), or at 36 after a Half grid's binary16 pair. */
|
|
42
|
+
rootAverage: 40,
|
|
43
|
+
rootHalfAverage: 36,
|
|
44
|
+
/** Half (K7.H): background, min and max are binary16 at 28/30/32 (`pnanovdb_grid_type_constants` row 9). */
|
|
45
|
+
rootHalfBackground: 28,
|
|
46
|
+
rootHalfMin: 30,
|
|
47
|
+
rootHalfMax: 32,
|
|
48
|
+
/** Smallest `RootData` for the supported types (stride table `root_size`). */
|
|
49
|
+
rootSize: 64,
|
|
50
|
+
};
|
|
51
|
+
/** `GridData.mFlags` bit for min/max statistics (NanoVDB `GridFlags::HasMinMax`). */
|
|
52
|
+
export const NANOVDB_FLAG_HAS_MIN_MAX = 1 << 2;
|
|
53
|
+
/** `GridData.mFlags` bit for the average statistic (NanoVDB `GridFlags::HasAverage`). */
|
|
54
|
+
export const NANOVDB_FLAG_HAS_AVERAGE = 1 << 3;
|
|
55
|
+
/** NanoVDB ABI major this core reads. */
|
|
56
|
+
export const NANOVDB_ABI_MAJOR = 32;
|
|
57
|
+
/** `"NanoVDB1"` (grid) as two little-endian u32 words. */
|
|
58
|
+
const MAGIC_GRID_LO = 0x6f6e614e; // "Nano"
|
|
59
|
+
const MAGIC_GRID_HI_CURRENT = 0x31424456; // "VDB1"
|
|
60
|
+
const MAGIC_GRID_HI_LEGACY = 0x30424456; // "VDB0"
|
|
61
|
+
const TYPE_BY_ID = new Map(Object.entries(VDB_GRID_TYPE_IDS).map(([name, id]) => [id, name]));
|
|
62
|
+
/** Maps a NanoVDB `GridType` id to its pool type name, or `null` when the pool can't hold it. */
|
|
63
|
+
export function gridTypeName(id) {
|
|
64
|
+
return TYPE_BY_ID.get(id) ?? null;
|
|
65
|
+
}
|
|
66
|
+
/** NanoVDB `GridClass` names by id (NanoVDB.h). */
|
|
67
|
+
const GRID_CLASS_NAMES = [
|
|
68
|
+
"Unknown",
|
|
69
|
+
"LevelSet",
|
|
70
|
+
"FogVolume",
|
|
71
|
+
"Staggered",
|
|
72
|
+
"PointIndex",
|
|
73
|
+
"PointData",
|
|
74
|
+
"Topology",
|
|
75
|
+
"VoxelVolume",
|
|
76
|
+
"IndexGrid",
|
|
77
|
+
"TensorGrid",
|
|
78
|
+
"VoxelBVH",
|
|
79
|
+
];
|
|
80
|
+
/** NanoVDB `GridClass` name for an id (`"Unknown(n)"` past the known range). */
|
|
81
|
+
export function gridClassName(id) {
|
|
82
|
+
return GRID_CLASS_NAMES[id] ?? `Unknown(${id})`;
|
|
83
|
+
}
|
|
84
|
+
function bad(message) {
|
|
85
|
+
throw new VDBError("VDB_BAD_IMAGE", message);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Parses and validates the header of a NanoVDB grid image (one grid, as
|
|
89
|
+
* `NvdbFile` from `@pmndrs/vdb/tools` returns it). Throws `VDB_BAD_IMAGE` or
|
|
90
|
+
* `VDB_UNSUPPORTED_GRID_TYPE` with the fix in the message.
|
|
91
|
+
*/
|
|
92
|
+
export function readImageHeader(image, what = "image") {
|
|
93
|
+
if (!(image instanceof Uint32Array)) {
|
|
94
|
+
bad(`${what} must be a Uint32Array holding one NanoVDB grid (NvdbFile from @pmndrs/vdb/tools returns one per grid).`);
|
|
95
|
+
}
|
|
96
|
+
const O = NANOVDB_OFFSETS;
|
|
97
|
+
const byteLength = image.byteLength;
|
|
98
|
+
const minBytes = O.gridSize + O.treeSize + O.rootSize;
|
|
99
|
+
if (byteLength < minBytes) {
|
|
100
|
+
bad(`${what} is ${byteLength} bytes; a NanoVDB grid is at least ${minBytes}. Pass a whole grid image, not a slice.`);
|
|
101
|
+
}
|
|
102
|
+
const view = new DataView(image.buffer, image.byteOffset, byteLength);
|
|
103
|
+
const u32 = (at) => view.getUint32(at, true);
|
|
104
|
+
const magicLo = u32(O.gridMagic);
|
|
105
|
+
const magicHi = u32(O.gridMagic + 4);
|
|
106
|
+
if (magicLo !== MAGIC_GRID_LO || (magicHi !== MAGIC_GRID_HI_CURRENT && magicHi !== MAGIC_GRID_HI_LEGACY)) {
|
|
107
|
+
bad(`${what} does not start with the NanoVDB grid magic "NanoVDB1". Pass a grid image (NvdbFile.grids[i].image), ` +
|
|
108
|
+
`not a whole .nvdb file.`);
|
|
109
|
+
}
|
|
110
|
+
const version = u32(O.gridVersion);
|
|
111
|
+
const major = (version >>> 21) & 0x7ff;
|
|
112
|
+
if (major !== NANOVDB_ABI_MAJOR) {
|
|
113
|
+
bad(`${what} is NanoVDB ABI ${major}.${(version >>> 10) & 0x7ff}; this core reads ABI ${NANOVDB_ABI_MAJOR}. ` +
|
|
114
|
+
`Re-export it with NanoVDB ${NANOVDB_ABI_MAJOR}.x.`);
|
|
115
|
+
}
|
|
116
|
+
const sizeLo = u32(O.gridByteSize);
|
|
117
|
+
const sizeHi = u32(O.gridByteSize + 4);
|
|
118
|
+
if (sizeHi !== 0) {
|
|
119
|
+
bad(`${what} declares a grid of 4 GiB or more; the pool addresses images with 32 bits. Split or downsample the grid.`);
|
|
120
|
+
}
|
|
121
|
+
if (sizeLo !== byteLength) {
|
|
122
|
+
bad(`${what} declares mGridSize ${sizeLo} but the array holds ${byteLength} bytes. Pass exactly one grid ` +
|
|
123
|
+
`(a multi-grid buffer must be split, which NvdbFile does).`);
|
|
124
|
+
}
|
|
125
|
+
const gridTypeId = u32(O.gridType);
|
|
126
|
+
const gridType = gridTypeName(gridTypeId);
|
|
127
|
+
if (gridType === null) {
|
|
128
|
+
throw new VDBError("VDB_UNSUPPORTED_GRID_TYPE", `${what} has NanoVDB GridType ${gridTypeId}; the pool holds Float (1), Half (9), Fp4 (13), Fp8 (14), Fp16 (15) and FpN (16). ` +
|
|
129
|
+
`Convert it, e.g. quantize() from @pmndrs/vdb/tools or nanovdb_convert --fp8.`);
|
|
130
|
+
}
|
|
131
|
+
const flags = u32(O.gridFlags);
|
|
132
|
+
const gridClass = u32(O.gridClass);
|
|
133
|
+
if (gridClass > 0xff)
|
|
134
|
+
bad(`${what} has GridClass ${gridClass}; NanoVDB classes are < 256, so the header is corrupt. Re-export it.`);
|
|
135
|
+
const f64s = (at, n) => {
|
|
136
|
+
const out = new Float64Array(n);
|
|
137
|
+
for (let k = 0; k < n; k++)
|
|
138
|
+
out[k] = view.getFloat64(at + 8 * k, true);
|
|
139
|
+
return out;
|
|
140
|
+
};
|
|
141
|
+
const matD = f64s(O.gridMap + O.mapMatD, 9);
|
|
142
|
+
const invMatD = f64s(O.gridMap + O.mapInvMatD, 9);
|
|
143
|
+
const vecD = f64s(O.gridMap + O.mapVecD, 3);
|
|
144
|
+
for (const [label, arr] of [["matD", matD], ["invMatD", invMatD], ["vecD", vecD]]) {
|
|
145
|
+
if (!arr.every(Number.isFinite)) {
|
|
146
|
+
bad(`${what} has a non-finite map (${label}). Rewrite its transform (transform() in @pmndrs/vdb/tools) and re-add it.`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const det = matD[0] * (matD[4] * matD[8] - matD[5] * matD[7]) -
|
|
150
|
+
matD[1] * (matD[3] * matD[8] - matD[5] * matD[6]) +
|
|
151
|
+
matD[2] * (matD[3] * matD[7] - matD[4] * matD[6]);
|
|
152
|
+
if (det === 0)
|
|
153
|
+
bad(`${what} has a singular map (zero voxel size). Rewrite its transform and re-add it.`);
|
|
154
|
+
const voxelSize = Array.from(f64s(O.gridVoxelSize, 3));
|
|
155
|
+
const rootRel = Number(view.getBigUint64(O.gridSize + O.treeNodeOffsetRoot, true));
|
|
156
|
+
const root = O.gridSize + rootRel;
|
|
157
|
+
if (!Number.isSafeInteger(rootRel) || root + O.rootSize > byteLength) {
|
|
158
|
+
bad(`${what} has a root node offset (${rootRel}) outside the image. The file is corrupt; re-export it.`);
|
|
159
|
+
}
|
|
160
|
+
const i3 = (at) => [view.getInt32(at, true), view.getInt32(at + 4, true), view.getInt32(at + 8, true)];
|
|
161
|
+
const nameBytes = new Uint8Array(image.buffer, image.byteOffset + O.gridName, O.gridNameMax);
|
|
162
|
+
let end = nameBytes.indexOf(0);
|
|
163
|
+
if (end < 0)
|
|
164
|
+
end = nameBytes.length;
|
|
165
|
+
const name = new TextDecoder().decode(nameBytes.subarray(0, end));
|
|
166
|
+
return {
|
|
167
|
+
gridType,
|
|
168
|
+
gridTypeId,
|
|
169
|
+
gridClass,
|
|
170
|
+
name,
|
|
171
|
+
flags,
|
|
172
|
+
hasStats: (flags & NANOVDB_FLAG_HAS_MIN_MAX) !== 0,
|
|
173
|
+
byteLength,
|
|
174
|
+
matD,
|
|
175
|
+
invMatD,
|
|
176
|
+
vecD,
|
|
177
|
+
indexBBoxMin: i3(root + O.rootBBoxMin),
|
|
178
|
+
indexBBoxMax: i3(root + O.rootBBoxMax),
|
|
179
|
+
voxelSize,
|
|
180
|
+
...(gridType === "half"
|
|
181
|
+
? {
|
|
182
|
+
background: halfBitsToNumber(view.getUint16(root + O.rootHalfBackground, true)),
|
|
183
|
+
rootMin: halfBitsToNumber(view.getUint16(root + O.rootHalfMin, true)),
|
|
184
|
+
rootMax: halfBitsToNumber(view.getUint16(root + O.rootHalfMax, true)),
|
|
185
|
+
}
|
|
186
|
+
: {
|
|
187
|
+
background: view.getFloat32(root + O.rootBackground, true),
|
|
188
|
+
rootMin: view.getFloat32(root + O.rootMin, true),
|
|
189
|
+
rootMax: view.getFloat32(root + O.rootMax, true),
|
|
190
|
+
}),
|
|
191
|
+
rootAverage: (flags & NANOVDB_FLAG_HAS_AVERAGE) !== 0 ? view.getFloat32(root + (gridType === "half" ? O.rootHalfAverage : O.rootAverage), true) : Number.NaN,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=image-header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-header.js","sourceRoot":"","sources":["../../../src/core/pool/image-header.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAwB,MAAM,aAAa,CAAC;AAGtE,iEAAiE;AACjE,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,8CAA8C;IAC9C,QAAQ,EAAE,GAAG;IACb,SAAS,EAAE,C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IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;gBAC/E,OAAO,EAAE,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBACrE,OAAO,EAAE,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;aACtE;YACH,CAAC,CAAC;gBACE,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,IAAI,CAAC;gBAC1D,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC;gBAChD,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC;aACjD,CAAC;QACN,WAAW,EACT,CAAC,KAAK,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG;KAClJ,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Reads the few NanoVDB `GridData` / `TreeData` / `RootData` fields a pool record\n * needs, by byte offset (docs/dev/design/K1-core.md §1.4). The core never imports\n * `tools` (D20), so the offsets are restated here; `test/core/image-header.test.ts`\n * cross-checks every one against `tools`' constants and `vendor/stride-tables.json`\n * (ABI 32.11.0, PNanoVDB.h; the offsets are those of 32.9.1).\n */\n\nimport { VDBError } from \"../errors.js\";\nimport { halfBitsToNumber } from \"../half.js\";\nimport { VDB_GRID_TYPE_IDS, type VDBGridTypeName } from \"../types.js\";\nimport type { VDBVec3 } from \"./layout.js\";\n\n/** Byte offsets inside a NanoVDB grid image used by the pool. */\nexport const NANOVDB_OFFSETS = {\n /** `GridData` size; `TreeData` follows it. */\n gridSize: 672,\n gridMagic: 0,\n gridVersion: 16,\n gridFlags: 20,\n /** u64 `mGridSize`. */\n gridByteSize: 32,\n gridName: 40,\n gridNameMax: 256,\n gridMap: 296,\n mapMatD: 88,\n mapInvMatD: 160,\n mapVecD: 232,\n gridWorldBBox: 560,\n gridVoxelSize: 608,\n gridClass: 632,\n gridType: 636,\n treeSize: 64,\n /** u64, relative to `TreeData`. */\n treeNodeOffsetRoot: 24,\n rootBBoxMin: 0,\n rootBBoxMax: 12,\n /** `RootData` base size before the typed background/stats. */\n rootBaseSize: 28,\n /** Typed root fields for Float/Fp4/Fp8/Fp16/FpN (all store f32 here). */\n rootBackground: 28,\n rootMin: 32,\n rootMax: 36,\n /** The average statistic is f32 for every scalar type: after min / max (f32: 40), or at 36 after a Half grid's binary16 pair. */\n rootAverage: 40,\n rootHalfAverage: 36,\n /** Half (K7.H): background, min and max are binary16 at 28/30/32 (`pnanovdb_grid_type_constants` row 9). */\n rootHalfBackground: 28,\n rootHalfMin: 30,\n rootHalfMax: 32,\n /** Smallest `RootData` for the supported types (stride table `root_size`). */\n rootSize: 64,\n} as const;\n\n/** `GridData.mFlags` bit for min/max statistics (NanoVDB `GridFlags::HasMinMax`). */\nexport const NANOVDB_FLAG_HAS_MIN_MAX = 1 << 2;\n/** `GridData.mFlags` bit for the average statistic (NanoVDB `GridFlags::HasAverage`). */\nexport const NANOVDB_FLAG_HAS_AVERAGE = 1 << 3;\n\n/** NanoVDB ABI major this core reads. */\nexport const NANOVDB_ABI_MAJOR = 32;\n\n/** `\"NanoVDB1\"` (grid) as two little-endian u32 words. */\nconst MAGIC_GRID_LO = 0x6f6e614e; // \"Nano\"\nconst MAGIC_GRID_HI_CURRENT = 0x31424456; // \"VDB1\"\nconst MAGIC_GRID_HI_LEGACY = 0x30424456; // \"VDB0\"\n\nconst TYPE_BY_ID = new Map<number, VDBGridTypeName>(\n (Object.entries(VDB_GRID_TYPE_IDS) as [VDBGridTypeName, number][]).map(([name, id]) => [id, name]),\n);\n\n/** Maps a NanoVDB `GridType` id to its pool type name, or `null` when the pool can't hold it. */\nexport function gridTypeName(id: number): VDBGridTypeName | null {\n return TYPE_BY_ID.get(id) ?? null;\n}\n\n/** NanoVDB `GridClass` names by id (NanoVDB.h). */\nconst GRID_CLASS_NAMES = [\n \"Unknown\",\n \"LevelSet\",\n \"FogVolume\",\n \"Staggered\",\n \"PointIndex\",\n \"PointData\",\n \"Topology\",\n \"VoxelVolume\",\n \"IndexGrid\",\n \"TensorGrid\",\n \"VoxelBVH\",\n] as const;\n\n/** NanoVDB `GridClass` name for an id (`\"Unknown(n)\"` past the known range). */\nexport function gridClassName(id: number): string {\n return GRID_CLASS_NAMES[id] ?? `Unknown(${id})`;\n}\n\n/** What the pool reads from a grid image's header. */\nexport interface VDBImageHeader {\n gridType: VDBGridTypeName;\n gridTypeId: number;\n gridClass: number;\n name: string;\n /** `GridData.mFlags`. */\n flags: number;\n hasStats: boolean;\n /** Bytes in the image (`mGridSize`, equal to the array's byte length). */\n byteLength: number;\n /** f64 3x3 row-major index -> world linear part. */\n matD: Float64Array;\n /** f64 3x3 row-major world -> index linear part. */\n invMatD: Float64Array;\n /** f64 translation: `world = matD * ijk + vecD`. */\n vecD: Float64Array;\n indexBBoxMin: VDBVec3;\n indexBBoxMax: VDBVec3;\n voxelSize: VDBVec3;\n background: number;\n /** Root min statistic (f32 as stored; a Half grid's binary16 decoded exactly); meaningful only when `hasStats`. */\n rootMin: number;\n /** Root max statistic; meaningful only when `hasStats`. */\n rootMax: number;\n /** Root average statistic (the mean of the active values, f32), or NaN when the image has none (`GridFlags::HasAverage` clear). */\n rootAverage: number;\n}\n\nfunction bad(message: string): never {\n throw new VDBError(\"VDB_BAD_IMAGE\", message);\n}\n\n/**\n * Parses and validates the header of a NanoVDB grid image (one grid, as\n * `NvdbFile` from `@pmndrs/vdb/tools` returns it). Throws `VDB_BAD_IMAGE` or\n * `VDB_UNSUPPORTED_GRID_TYPE` with the fix in the message.\n */\nexport function readImageHeader(image: Uint32Array, what = \"image\"): VDBImageHeader {\n if (!(image instanceof Uint32Array)) {\n bad(`${what} must be a Uint32Array holding one NanoVDB grid (NvdbFile from @pmndrs/vdb/tools returns one per grid).`);\n }\n const O = NANOVDB_OFFSETS;\n const byteLength = image.byteLength;\n const minBytes = O.gridSize + O.treeSize + O.rootSize;\n if (byteLength < minBytes) {\n bad(`${what} is ${byteLength} bytes; a NanoVDB grid is at least ${minBytes}. Pass a whole grid image, not a slice.`);\n }\n const view = new DataView(image.buffer, image.byteOffset, byteLength);\n const u32 = (at: number) => view.getUint32(at, true);\n\n const magicLo = u32(O.gridMagic);\n const magicHi = u32(O.gridMagic + 4);\n if (magicLo !== MAGIC_GRID_LO || (magicHi !== MAGIC_GRID_HI_CURRENT && magicHi !== MAGIC_GRID_HI_LEGACY)) {\n bad(\n `${what} does not start with the NanoVDB grid magic \"NanoVDB1\". Pass a grid image (NvdbFile.grids[i].image), ` +\n `not a whole .nvdb file.`,\n );\n }\n const version = u32(O.gridVersion);\n const major = (version >>> 21) & 0x7ff;\n if (major !== NANOVDB_ABI_MAJOR) {\n bad(\n `${what} is NanoVDB ABI ${major}.${(version >>> 10) & 0x7ff}; this core reads ABI ${NANOVDB_ABI_MAJOR}. ` +\n `Re-export it with NanoVDB ${NANOVDB_ABI_MAJOR}.x.`,\n );\n }\n const sizeLo = u32(O.gridByteSize);\n const sizeHi = u32(O.gridByteSize + 4);\n if (sizeHi !== 0) {\n bad(`${what} declares a grid of 4 GiB or more; the pool addresses images with 32 bits. Split or downsample the grid.`);\n }\n if (sizeLo !== byteLength) {\n bad(\n `${what} declares mGridSize ${sizeLo} but the array holds ${byteLength} bytes. Pass exactly one grid ` +\n `(a multi-grid buffer must be split, which NvdbFile does).`,\n );\n }\n\n const gridTypeId = u32(O.gridType);\n const gridType = gridTypeName(gridTypeId);\n if (gridType === null) {\n throw new VDBError(\n \"VDB_UNSUPPORTED_GRID_TYPE\",\n `${what} has NanoVDB GridType ${gridTypeId}; the pool holds Float (1), Half (9), Fp4 (13), Fp8 (14), Fp16 (15) and FpN (16). ` +\n `Convert it, e.g. quantize() from @pmndrs/vdb/tools or nanovdb_convert --fp8.`,\n );\n }\n const flags = u32(O.gridFlags);\n const gridClass = u32(O.gridClass);\n if (gridClass > 0xff) bad(`${what} has GridClass ${gridClass}; NanoVDB classes are < 256, so the header is corrupt. Re-export it.`);\n\n const f64s = (at: number, n: number) => {\n const out = new Float64Array(n);\n for (let k = 0; k < n; k++) out[k] = view.getFloat64(at + 8 * k, true);\n return out;\n };\n const matD = f64s(O.gridMap + O.mapMatD, 9);\n const invMatD = f64s(O.gridMap + O.mapInvMatD, 9);\n const vecD = f64s(O.gridMap + O.mapVecD, 3);\n for (const [label, arr] of [[\"matD\", matD], [\"invMatD\", invMatD], [\"vecD\", vecD]] as const) {\n if (!arr.every(Number.isFinite)) {\n bad(`${what} has a non-finite map (${label}). Rewrite its transform (transform() in @pmndrs/vdb/tools) and re-add it.`);\n }\n }\n const det =\n matD[0]! * (matD[4]! * matD[8]! - matD[5]! * matD[7]!) -\n matD[1]! * (matD[3]! * matD[8]! - matD[5]! * matD[6]!) +\n matD[2]! * (matD[3]! * matD[7]! - matD[4]! * matD[6]!);\n if (det === 0) bad(`${what} has a singular map (zero voxel size). Rewrite its transform and re-add it.`);\n const voxelSize = Array.from(f64s(O.gridVoxelSize, 3)) as VDBVec3;\n\n const rootRel = Number(view.getBigUint64(O.gridSize + O.treeNodeOffsetRoot, true));\n const root = O.gridSize + rootRel;\n if (!Number.isSafeInteger(rootRel) || root + O.rootSize > byteLength) {\n bad(`${what} has a root node offset (${rootRel}) outside the image. The file is corrupt; re-export it.`);\n }\n const i3 = (at: number): VDBVec3 => [view.getInt32(at, true), view.getInt32(at + 4, true), view.getInt32(at + 8, true)];\n\n const nameBytes = new Uint8Array(image.buffer, image.byteOffset + O.gridName, O.gridNameMax);\n let end = nameBytes.indexOf(0);\n if (end < 0) end = nameBytes.length;\n const name = new TextDecoder().decode(nameBytes.subarray(0, end));\n\n return {\n gridType,\n gridTypeId,\n gridClass,\n name,\n flags,\n hasStats: (flags & NANOVDB_FLAG_HAS_MIN_MAX) !== 0,\n byteLength,\n matD,\n invMatD,\n vecD,\n indexBBoxMin: i3(root + O.rootBBoxMin),\n indexBBoxMax: i3(root + O.rootBBoxMax),\n voxelSize,\n ...(gridType === \"half\"\n ? {\n background: halfBitsToNumber(view.getUint16(root + O.rootHalfBackground, true)),\n rootMin: halfBitsToNumber(view.getUint16(root + O.rootHalfMin, true)),\n rootMax: halfBitsToNumber(view.getUint16(root + O.rootHalfMax, true)),\n }\n : {\n background: view.getFloat32(root + O.rootBackground, true),\n rootMin: view.getFloat32(root + O.rootMin, true),\n rootMax: view.getFloat32(root + O.rootMax, true),\n }),\n rootAverage:\n (flags & NANOVDB_FLAG_HAS_AVERAGE) !== 0 ? view.getFloat32(root + (gridType === \"half\" ? O.rootHalfAverage : O.rootAverage), true) : Number.NaN,\n };\n}\n"]}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pool buffer layout 1 (docs/dev/design/K1-core.md §1): a 32-byte header, a table of
|
|
3
|
+
* fixed-stride 160-byte grid records, then 32-byte-aligned ranges (NanoVDB
|
|
4
|
+
* images, brick-majorant grids).
|
|
5
|
+
*
|
|
6
|
+
* This file is the single source of truth for every header word, record word
|
|
7
|
+
* and flag bit. The TypeScript encoders below and the WGSL constants returned by
|
|
8
|
+
* {@link vdbPoolLayoutWgsl} are both derived from the tables in this file, so the
|
|
9
|
+
* CPU writer and the GPU reader cannot drift apart. Any change to a word or its
|
|
10
|
+
* meaning bumps {@link VDB_GPU_LAYOUT_VERSION} and is a breaking change (§1.8).
|
|
11
|
+
*/
|
|
12
|
+
import type { VDBVec3 } from "../../tools/vdb/types.js";
|
|
13
|
+
/** Layout version written to header word 1 and baked into generated WGSL. */
|
|
14
|
+
export declare const VDB_GPU_LAYOUT_VERSION = 1;
|
|
15
|
+
/** Header word 0: `"VDBP"` read as a little-endian u32. */
|
|
16
|
+
export declare const VDB_POOL_MAGIC = 1346520150;
|
|
17
|
+
/** Every range in the pool (table, images, majorants) starts on this byte alignment (NanoVDB's data alignment). */
|
|
18
|
+
export declare const VDB_POOL_ALIGN = 32;
|
|
19
|
+
/** Header size in bytes. */
|
|
20
|
+
export declare const VDB_POOL_HEADER_BYTES = 32;
|
|
21
|
+
/** Header size in u32 words. */
|
|
22
|
+
export declare const VDB_POOL_HEADER_WORDS: number;
|
|
23
|
+
/** Byte offset of record 0 (fixed in layout 1). */
|
|
24
|
+
export declare const VDB_POOL_TABLE_OFFSET = 32;
|
|
25
|
+
/** Grid record size in bytes. A multiple of 16 so `vec4` loads stay possible. */
|
|
26
|
+
export declare const VDB_POOL_RECORD_BYTES = 160;
|
|
27
|
+
/** Grid record size in u32 words. */
|
|
28
|
+
export declare const VDB_POOL_RECORD_WORDS: number;
|
|
29
|
+
/** Header word indices (§1.1). */
|
|
30
|
+
export declare const VDB_HEADER_WORD: {
|
|
31
|
+
/** {@link VDB_POOL_MAGIC}. */
|
|
32
|
+
readonly magic: 0;
|
|
33
|
+
/** {@link VDB_GPU_LAYOUT_VERSION}. */
|
|
34
|
+
readonly layoutVersion: 1;
|
|
35
|
+
/** Records in the table. */
|
|
36
|
+
readonly gridCapacity: 2;
|
|
37
|
+
/** Highest live grid id + 1 (`vdbGridCount()` in WGSL). */
|
|
38
|
+
readonly gridCount: 3;
|
|
39
|
+
/** {@link VDB_POOL_TABLE_OFFSET}, written for readers that don't know the version. */
|
|
40
|
+
readonly tableOffset: 4;
|
|
41
|
+
/** {@link VDB_POOL_RECORD_BYTES}. */
|
|
42
|
+
readonly recordBytes: 5;
|
|
43
|
+
/** Allocation high-water mark in bytes (diagnostics). */
|
|
44
|
+
readonly usedBytes: 6;
|
|
45
|
+
/** Always 0 in layout 1. */
|
|
46
|
+
readonly reserved: 7;
|
|
47
|
+
};
|
|
48
|
+
/** Grid record word indices (§1.2). Multi-word fields name their first word. */
|
|
49
|
+
export declare const VDB_RECORD_WORD: {
|
|
50
|
+
/** u32: image byte offset from the start of the pool; a multiple of 32. */
|
|
51
|
+
readonly imageOffset: 0;
|
|
52
|
+
/** u32: NanoVDB `GridData.mGridSize` (its high word must be 0). */
|
|
53
|
+
readonly imageBytes: 1;
|
|
54
|
+
/** u32: NanoVDB `GridType` id (1 Float, 9 Half, 13 Fp4, 14 Fp8, 15 Fp16, 16 FpN). */
|
|
55
|
+
readonly gridType: 2;
|
|
56
|
+
/** u32: see {@link VDB_RECORD_FLAG} and the class / brick-log2 bit fields. */
|
|
57
|
+
readonly flags: 3;
|
|
58
|
+
/** f32 x12: world -> index, 3x4 row-major (`idx = M * [p, 1]`). */
|
|
59
|
+
readonly worldToIndex: 4;
|
|
60
|
+
/** f32 x12: index -> world, 3x4 row-major. */
|
|
61
|
+
readonly indexToWorld: 16;
|
|
62
|
+
/** i32 x3: root active bbox min. */
|
|
63
|
+
readonly indexBBoxMin: 28;
|
|
64
|
+
/** f32: root background value. */
|
|
65
|
+
readonly background: 31;
|
|
66
|
+
/** i32 x3: root active bbox max (inclusive). */
|
|
67
|
+
readonly indexBBoxMax: 32;
|
|
68
|
+
/** f32: `max(root max stat, background)` or the caller's bound; the `global` majorant. */
|
|
69
|
+
readonly valueMax: 35;
|
|
70
|
+
/** u32: brick-majorant range byte offset; 0 = none. */
|
|
71
|
+
readonly majorantOffset: 36;
|
|
72
|
+
/** u32 x3: brick-majorant grid dimensions in cells. */
|
|
73
|
+
readonly majorantDims: 37;
|
|
74
|
+
};
|
|
75
|
+
/** Single-bit record flags (record word 3). */
|
|
76
|
+
export declare const VDB_RECORD_FLAG: {
|
|
77
|
+
/** b0: the record describes a live grid; a dead id reads 0 everywhere. */
|
|
78
|
+
readonly live: number;
|
|
79
|
+
/** b1: the image carries min/max stats (`GridData` flag `HasMinMax`). */
|
|
80
|
+
readonly hasStats: number;
|
|
81
|
+
/** b2: `majorantOffset`/`majorantDims` describe a brick-majorant range. */
|
|
82
|
+
readonly hasBrickMajorant: number;
|
|
83
|
+
/** b3: the affines include a host instance transform (`setTransform`). */
|
|
84
|
+
readonly instanceTransform: number;
|
|
85
|
+
};
|
|
86
|
+
/** Bit position of the 8-bit NanoVDB `GridClass` field in record word 3. */
|
|
87
|
+
export declare const VDB_RECORD_GRID_CLASS_SHIFT = 8;
|
|
88
|
+
/** Bit position of the 8-bit brick log2 field in record word 3. */
|
|
89
|
+
export declare const VDB_RECORD_BRICK_LOG2_SHIFT = 16;
|
|
90
|
+
/** Mask (after shifting) of the 8-bit class and brick-log2 fields. */
|
|
91
|
+
export declare const VDB_RECORD_BYTE_FIELD_MASK = 255;
|
|
92
|
+
/**
|
|
93
|
+
* A brick-majorant range (P1.3; record words 36-39 point at it): a 32-byte header, then
|
|
94
|
+
* `dims.x * dims.y * dims.z` f32 upper bounds (x fastest), then as many lower bounds when the header's
|
|
95
|
+
* minima flag is set. The header carries what the record has no room for: the index position of cell 0's
|
|
96
|
+
* min corner and the flags. Layout 1 never defined the range's bytes (no 0.1 module read them, D22); the
|
|
97
|
+
* magic lets a module tell a P1 range from a 0.1 pool's bare bounds and walk the latter as `global`.
|
|
98
|
+
*/
|
|
99
|
+
export declare const VDB_MAJORANT_HEADER_BYTES = 32;
|
|
100
|
+
/** Majorant header word 4: `"VDBM"` read as a little-endian u32. */
|
|
101
|
+
export declare const VDB_MAJORANT_MAGIC = 1296188502;
|
|
102
|
+
/** Majorant range header word indices. */
|
|
103
|
+
export declare const VDB_MAJORANT_WORD: {
|
|
104
|
+
/** i32 x3: index position of cell 0's min corner. */
|
|
105
|
+
readonly origin: 0;
|
|
106
|
+
/** u32: see {@link VDB_MAJORANT_FLAG}. */
|
|
107
|
+
readonly flags: 3;
|
|
108
|
+
/** {@link VDB_MAJORANT_MAGIC}. */
|
|
109
|
+
readonly magic: 4;
|
|
110
|
+
};
|
|
111
|
+
/** Majorant range header flag bits (word 3). */
|
|
112
|
+
export declare const VDB_MAJORANT_FLAG: {
|
|
113
|
+
/** b0: lower bounds follow the upper bounds. */
|
|
114
|
+
readonly minima: number;
|
|
115
|
+
};
|
|
116
|
+
/** Packs a brick majorant's range: header, upper bounds, optional lower bounds. `bytes` is its size. */
|
|
117
|
+
export declare function encodeMajorantRange(m: {
|
|
118
|
+
readonly origin: VDBVec3;
|
|
119
|
+
readonly dims: VDBVec3;
|
|
120
|
+
readonly data: Float32Array;
|
|
121
|
+
readonly minima?: Float32Array | undefined;
|
|
122
|
+
}): Float32Array;
|
|
123
|
+
/** Decoded pool header (§1.1). */
|
|
124
|
+
export interface VDBPoolHeader {
|
|
125
|
+
magic: number;
|
|
126
|
+
layoutVersion: number;
|
|
127
|
+
gridCapacity: number;
|
|
128
|
+
gridCount: number;
|
|
129
|
+
tableOffset: number;
|
|
130
|
+
recordBytes: number;
|
|
131
|
+
usedBytes: number;
|
|
132
|
+
}
|
|
133
|
+
export type { VDBVec3 };
|
|
134
|
+
/**
|
|
135
|
+
* Decoded grid record (§1.2). Affines hold the f32-rounded values the GPU sees;
|
|
136
|
+
* 12 entries each, 3x4 row-major.
|
|
137
|
+
*/
|
|
138
|
+
export interface VDBGridRecord {
|
|
139
|
+
imageOffset: number;
|
|
140
|
+
imageBytes: number;
|
|
141
|
+
gridType: number;
|
|
142
|
+
live: boolean;
|
|
143
|
+
hasStats: boolean;
|
|
144
|
+
hasBrickMajorant: boolean;
|
|
145
|
+
instanceTransform: boolean;
|
|
146
|
+
/** NanoVDB `GridClass` id (0-255). */
|
|
147
|
+
gridClass: number;
|
|
148
|
+
/** log2 of the brick edge in voxels (0-255; 0 when there is no brick majorant). */
|
|
149
|
+
brickLog2: number;
|
|
150
|
+
worldToIndex: number[];
|
|
151
|
+
indexToWorld: number[];
|
|
152
|
+
indexBBoxMin: VDBVec3;
|
|
153
|
+
indexBBoxMax: VDBVec3;
|
|
154
|
+
background: number;
|
|
155
|
+
valueMax: number;
|
|
156
|
+
majorantOffset: number;
|
|
157
|
+
majorantDims: VDBVec3;
|
|
158
|
+
}
|
|
159
|
+
/** Rounds `n` up to the pool alignment ({@link VDB_POOL_ALIGN}). */
|
|
160
|
+
export declare function align32(n: number): number;
|
|
161
|
+
/** Byte offset of record `id`. */
|
|
162
|
+
export declare function recordByteOffset(id: number): number;
|
|
163
|
+
/** First byte after a table of `capacity` records, aligned: where ranges may start. */
|
|
164
|
+
export declare function dataStartOffset(capacity: number): number;
|
|
165
|
+
/** Writes the header's 8 words into `out` at `wordOffset` and returns `out`. */
|
|
166
|
+
export declare function encodeHeader(header: Omit<VDBPoolHeader, "magic" | "layoutVersion" | "tableOffset" | "recordBytes">, out?: Uint32Array, wordOffset?: number): Uint32Array;
|
|
167
|
+
/** Reads a header from `words` at `wordOffset` (no validation; see {@link VDBPoolHeader}). */
|
|
168
|
+
export declare function decodeHeader(words: Uint32Array, wordOffset?: number): VDBPoolHeader;
|
|
169
|
+
/**
|
|
170
|
+
* Writes `record` as 40 words into `out` at `wordOffset` and returns `out`.
|
|
171
|
+
* Affines are rounded to f32 here; pass the f64 values you composed.
|
|
172
|
+
*/
|
|
173
|
+
export declare function encodeRecord(record: VDBGridRecord, out?: Uint32Array, wordOffset?: number): Uint32Array;
|
|
174
|
+
/** Reads the 40-word record at `wordOffset` of `words`. */
|
|
175
|
+
export declare function decodeRecord(words: Uint32Array, wordOffset?: number): VDBGridRecord;
|
|
176
|
+
/**
|
|
177
|
+
* WGSL `const` declarations for layout {@link VDB_GPU_LAYOUT_VERSION}, generated
|
|
178
|
+
* from the tables in this file. Pure and deterministic: same package version,
|
|
179
|
+
* same text. Every name carries the `VDB_` prefix (D10, K1-core §3.4) and no
|
|
180
|
+
* comment contains a back-tick (CLAUDE.md Traps).
|
|
181
|
+
*
|
|
182
|
+
* Emitted names (all `u32`):
|
|
183
|
+
* - `VDB_GPU_LAYOUT_VERSION`, `VDB_POOL_MAGIC`
|
|
184
|
+
* - `VDB_POOL_TABLE_OFFSET` (bytes), `VDB_POOL_TABLE_WORD` (= offset / 4),
|
|
185
|
+
* `VDB_POOL_RECORD_BYTES`, `VDB_POOL_RECORD_WORDS`, `VDB_POOL_ALIGN`
|
|
186
|
+
* - `VDB_HEADER_<FIELD>` for every {@link VDB_HEADER_WORD} entry (word index),
|
|
187
|
+
* e.g. `VDB_HEADER_GRID_COUNT = 3u`
|
|
188
|
+
* - `VDB_REC_<FIELD>` for every {@link VDB_RECORD_WORD} entry (word index within
|
|
189
|
+
* a record), e.g. `VDB_REC_IMAGE_OFFSET = 0u`, `VDB_REC_WORLD_TO_INDEX = 4u`
|
|
190
|
+
* - `VDB_REC_FLAG_<NAME>` for every {@link VDB_RECORD_FLAG} bit, plus
|
|
191
|
+
* `VDB_REC_GRID_CLASS_SHIFT`, `VDB_REC_BRICK_LOG2_SHIFT`, `VDB_REC_BYTE_FIELD_MASK`
|
|
192
|
+
* - P1.3, the brick-majorant range header: `VDB_MAJORANT_MAGIC`, `VDB_MAJORANT_HEADER_WORDS`,
|
|
193
|
+
* `VDB_MAJ_<FIELD>` for every {@link VDB_MAJORANT_WORD} entry and `VDB_MAJ_FLAG_<NAME>` per
|
|
194
|
+
* {@link VDB_MAJORANT_FLAG} bit
|
|
195
|
+
*
|
|
196
|
+
* Word `w` of record `g` is `vdb_load(VDB_POOL_TABLE_WORD + g * VDB_POOL_RECORD_WORDS + w)`.
|
|
197
|
+
*/
|
|
198
|
+
export declare function vdbPoolLayoutWgsl(): string;
|