@pmndrs/vdb 0.0.0-stage → 0.1.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 +137 -0
- package/LICENSE +21 -0
- package/README.md +448 -2
- package/THIRD_PARTY_NOTICES.md +147 -0
- package/dist/core/compute/atlas.d.ts +94 -0
- package/dist/core/compute/atlas.js +98 -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/pyramid.d.ts +105 -0
- package/dist/core/compute/pyramid.js +455 -0
- package/dist/core/compute/pyramid.js.map +1 -0
- package/dist/core/compute/shared.d.ts +115 -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 +71 -0
- package/dist/core/compute/stats.js +188 -0
- package/dist/core/compute/stats.js.map +1 -0
- package/dist/core/compute/value-transform.d.ts +23 -0
- package/dist/core/compute/value-transform.js +58 -0
- package/dist/core/compute/value-transform.js.map +1 -0
- package/dist/core/errors.d.ts +11 -0
- package/dist/core/errors.js +9 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +30 -0
- package/dist/core/index.js +27 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/internal.d.ts +15 -0
- package/dist/core/internal.js +15 -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 +82 -0
- package/dist/core/pool/image-header.js +175 -0
- package/dist/core/pool/image-header.js.map +1 -0
- package/dist/core/pool/layout.d.ts +164 -0
- package/dist/core/pool/layout.js +267 -0
- package/dist/core/pool/layout.js.map +1 -0
- package/dist/core/pool/limits.d.ts +40 -0
- package/dist/core/pool/limits.js +79 -0
- package/dist/core/pool/limits.js.map +1 -0
- package/dist/core/pool/pool.d.ts +279 -0
- package/dist/core/pool/pool.js +953 -0
- package/dist/core/pool/pool.js.map +1 -0
- package/dist/core/source/dense.d.ts +19 -0
- package/dist/core/source/dense.js +287 -0
- package/dist/core/source/dense.js.map +1 -0
- package/dist/core/source/types.d.ts +63 -0
- package/dist/core/source/types.js +9 -0
- package/dist/core/source/types.js.map +1 -0
- package/dist/core/types.d.ts +28 -0
- package/dist/core/types.js +28 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/wgsl/api.d.ts +41 -0
- package/dist/core/wgsl/api.js +463 -0
- package/dist/core/wgsl/api.js.map +1 -0
- package/dist/core/wgsl/generate.d.ts +82 -0
- package/dist/core/wgsl/generate.js +505 -0
- package/dist/core/wgsl/generate.js.map +1 -0
- package/dist/core/wgsl/level-set.d.ts +54 -0
- package/dist/core/wgsl/level-set.js +194 -0
- package/dist/core/wgsl/level-set.js.map +1 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.js +330 -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 +104 -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 +162 -0
- package/dist/three/coarse-first.js +187 -0
- package/dist/three/coarse-first.js.map +1 -0
- package/dist/three/compute.d.ts +63 -0
- package/dist/three/compute.js +56 -0
- package/dist/three/compute.js.map +1 -0
- package/dist/three/device.d.ts +59 -0
- package/dist/three/device.js +59 -0
- package/dist/three/device.js.map +1 -0
- package/dist/three/frame/blackbody.d.ts +42 -0
- package/dist/three/frame/blackbody.js +74 -0
- package/dist/three/frame/blackbody.js.map +1 -0
- package/dist/three/frame/chunks.d.ts +157 -0
- package/dist/three/frame/chunks.js +559 -0
- package/dist/three/frame/chunks.js.map +1 -0
- package/dist/three/frame/density-material.d.ts +53 -0
- package/dist/three/frame/density-material.js +353 -0
- package/dist/three/frame/density-material.js.map +1 -0
- package/dist/three/frame/emission-light.d.ts +167 -0
- package/dist/three/frame/emission-light.js +655 -0
- package/dist/three/frame/emission-light.js.map +1 -0
- package/dist/three/frame/environment-grid-material.d.ts +21 -0
- package/dist/three/frame/environment-grid-material.js +184 -0
- package/dist/three/frame/environment-grid-material.js.map +1 -0
- package/dist/three/frame/environment-material.d.ts +22 -0
- package/dist/three/frame/environment-material.js +87 -0
- package/dist/three/frame/environment-material.js.map +1 -0
- package/dist/three/frame/grid-mip-material.d.ts +12 -0
- package/dist/three/frame/grid-mip-material.js +61 -0
- package/dist/three/frame/grid-mip-material.js.map +1 -0
- package/dist/three/frame/index.d.ts +39 -0
- package/dist/three/frame/index.js +35 -0
- package/dist/three/frame/index.js.map +1 -0
- package/dist/three/frame/inject-material.d.ts +56 -0
- package/dist/three/frame/inject-material.js +424 -0
- package/dist/three/frame/inject-material.js.map +1 -0
- package/dist/three/frame/integrate-material.d.ts +26 -0
- package/dist/three/frame/integrate-material.js +198 -0
- package/dist/three/frame/integrate-material.js.map +1 -0
- package/dist/three/frame/layout.d.ts +34 -0
- package/dist/three/frame/layout.js +48 -0
- package/dist/three/frame/layout.js.map +1 -0
- package/dist/three/frame/lighting-material.d.ts +41 -0
- package/dist/three/frame/lighting-material.js +257 -0
- package/dist/three/frame/lighting-material.js.map +1 -0
- package/dist/three/frame/lights.d.ts +11 -0
- package/dist/three/frame/lights.js +16 -0
- package/dist/three/frame/lights.js.map +1 -0
- package/dist/three/frame/medium.d.ts +21 -0
- package/dist/three/frame/medium.js +29 -0
- package/dist/three/frame/medium.js.map +1 -0
- package/dist/three/frame/neural.d.ts +14 -0
- package/dist/three/frame/neural.js +105 -0
- package/dist/three/frame/neural.js.map +1 -0
- package/dist/three/frame/phase.d.ts +44 -0
- package/dist/three/frame/phase.js +80 -0
- package/dist/three/frame/phase.js.map +1 -0
- package/dist/three/frame/renderer.d.ts +493 -0
- package/dist/three/frame/renderer.js +1498 -0
- package/dist/three/frame/renderer.js.map +1 -0
- package/dist/three/frame/shadow-density-material.d.ts +30 -0
- package/dist/three/frame/shadow-density-material.js +123 -0
- package/dist/three/frame/shadow-density-material.js.map +1 -0
- package/dist/three/frame/spectrum.d.ts +18 -0
- package/dist/three/frame/spectrum.js +36 -0
- package/dist/three/frame/spectrum.js.map +1 -0
- package/dist/three/frame/temporal-material.d.ts +29 -0
- package/dist/three/frame/temporal-material.js +152 -0
- package/dist/three/frame/temporal-material.js.map +1 -0
- package/dist/three/frame/three-internals.d.ts +65 -0
- package/dist/three/frame/three-internals.js +150 -0
- package/dist/three/frame/three-internals.js.map +1 -0
- package/dist/three/frame/transmittance-material.d.ts +31 -0
- package/dist/three/frame/transmittance-material.js +315 -0
- package/dist/three/frame/transmittance-material.js.map +1 -0
- package/dist/three/frame/view.d.ts +103 -0
- package/dist/three/frame/view.js +296 -0
- package/dist/three/frame/view.js.map +1 -0
- package/dist/three/frame/volume-shadow-material.d.ts +36 -0
- package/dist/three/frame/volume-shadow-material.js +128 -0
- package/dist/three/frame/volume-shadow-material.js.map +1 -0
- package/dist/three/frame/volume-shadows.d.ts +153 -0
- package/dist/three/frame/volume-shadows.js +756 -0
- package/dist/three/frame/volume-shadows.js.map +1 -0
- package/dist/three/frame/volume.d.ts +172 -0
- package/dist/three/frame/volume.js +256 -0
- package/dist/three/frame/volume.js.map +1 -0
- package/dist/three/grid-node.d.ts +196 -0
- package/dist/three/grid-node.js +510 -0
- package/dist/three/grid-node.js.map +1 -0
- package/dist/three/index.d.ts +43 -0
- package/dist/three/index.js +49 -0
- package/dist/three/index.js.map +1 -0
- package/dist/three/internal.d.ts +14 -0
- package/dist/three/internal.js +14 -0
- package/dist/three/internal.js.map +1 -0
- package/dist/three/level-set-material.d.ts +112 -0
- package/dist/three/level-set-material.js +204 -0
- package/dist/three/level-set-material.js.map +1 -0
- package/dist/three/material.d.ts +194 -0
- package/dist/three/material.js +359 -0
- package/dist/three/material.js.map +1 -0
- package/dist/three/points.d.ts +84 -0
- package/dist/three/points.js +130 -0
- package/dist/three/points.js.map +1 -0
- package/dist/three/sequence.d.ts +317 -0
- package/dist/three/sequence.js +526 -0
- package/dist/three/sequence.js.map +1 -0
- package/dist/three/sparse-source.d.ts +233 -0
- package/dist/three/sparse-source.js +876 -0
- package/dist/three/sparse-source.js.map +1 -0
- package/dist/three/volume-source.d.ts +167 -0
- package/dist/three/volume-source.js +353 -0
- package/dist/three/volume-source.js.map +1 -0
- package/dist/tools/cpu/compute.d.ts +97 -0
- package/dist/tools/cpu/compute.js +218 -0
- package/dist/tools/cpu/compute.js.map +1 -0
- package/dist/tools/cpu/level-set.d.ts +72 -0
- package/dist/tools/cpu/level-set.js +261 -0
- package/dist/tools/cpu/level-set.js.map +1 -0
- package/dist/tools/cpu/march.d.ts +206 -0
- package/dist/tools/cpu/march.js +575 -0
- package/dist/tools/cpu/march.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 +31 -0
- package/dist/tools/cpu/read-value.js +336 -0
- package/dist/tools/cpu/read-value.js.map +1 -0
- package/dist/tools/cpu/sample-trilinear.d.ts +30 -0
- package/dist/tools/cpu/sample-trilinear.js +156 -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 +1058 -0
- package/dist/tools/cpu/stride-tables.generated.js +1266 -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/errors.d.ts +57 -0
- package/dist/tools/errors.js +58 -0
- package/dist/tools/errors.js.map +1 -0
- package/dist/tools/frame/blackbody.d.ts +42 -0
- package/dist/tools/frame/blackbody.js +116 -0
- package/dist/tools/frame/blackbody.js.map +1 -0
- package/dist/tools/frame/emission.d.ts +128 -0
- package/dist/tools/frame/emission.js +282 -0
- package/dist/tools/frame/emission.js.map +1 -0
- package/dist/tools/frame/environment.d.ts +105 -0
- package/dist/tools/frame/environment.js +268 -0
- package/dist/tools/frame/environment.js.map +1 -0
- package/dist/tools/frame/grid.d.ts +302 -0
- package/dist/tools/frame/grid.js +703 -0
- package/dist/tools/frame/grid.js.map +1 -0
- package/dist/tools/frame/index.d.ts +136 -0
- package/dist/tools/frame/index.js +348 -0
- package/dist/tools/frame/index.js.map +1 -0
- package/dist/tools/frame/medium.d.ts +61 -0
- package/dist/tools/frame/medium.js +99 -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 +54 -0
- package/dist/tools/frame/mie.js +176 -0
- package/dist/tools/frame/mie.js.map +1 -0
- package/dist/tools/frame/neural-weights.d.ts +9 -0
- package/dist/tools/frame/neural-weights.js +245 -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/pyramid-layout.d.ts +38 -0
- package/dist/tools/frame/pyramid-layout.js +53 -0
- package/dist/tools/frame/pyramid-layout.js.map +1 -0
- package/dist/tools/frame/shadows.d.ts +80 -0
- package/dist/tools/frame/shadows.js +182 -0
- package/dist/tools/frame/shadows.js.map +1 -0
- package/dist/tools/frame/sparse.d.ts +65 -0
- package/dist/tools/frame/sparse.js +191 -0
- package/dist/tools/frame/sparse.js.map +1 -0
- package/dist/tools/frame/spectral.d.ts +203 -0
- package/dist/tools/frame/spectral.js +550 -0
- package/dist/tools/frame/spectral.js.map +1 -0
- package/dist/tools/index.d.ts +106 -0
- package/dist/tools/index.js +88 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/internal.d.ts +46 -0
- package/dist/tools/internal.js +31 -0
- package/dist/tools/internal.js.map +1 -0
- package/dist/tools/nanovdb/build-from-vdb.d.ts +50 -0
- package/dist/tools/nanovdb/build-from-vdb.js +92 -0
- package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
- package/dist/tools/nanovdb/bytes.d.ts +220 -0
- package/dist/tools/nanovdb/bytes.js +345 -0
- package/dist/tools/nanovdb/bytes.js.map +1 -0
- package/dist/tools/nanovdb/coarse-first.d.ts +62 -0
- package/dist/tools/nanovdb/coarse-first.js +86 -0
- package/dist/tools/nanovdb/coarse-first.js.map +1 -0
- package/dist/tools/nanovdb/index.d.ts +32 -0
- package/dist/tools/nanovdb/index.js +24 -0
- package/dist/tools/nanovdb/index.js.map +1 -0
- package/dist/tools/nanovdb/inspect.d.ts +24 -0
- package/dist/tools/nanovdb/inspect.js +63 -0
- package/dist/tools/nanovdb/inspect.js.map +1 -0
- package/dist/tools/nanovdb/leaf-codec.d.ts +85 -0
- package/dist/tools/nanovdb/leaf-codec.js +320 -0
- package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
- package/dist/tools/nanovdb/quantize.d.ts +43 -0
- package/dist/tools/nanovdb/quantize.js +277 -0
- package/dist/tools/nanovdb/quantize.js.map +1 -0
- package/dist/tools/nanovdb/resample.d.ts +160 -0
- package/dist/tools/nanovdb/resample.js +679 -0
- package/dist/tools/nanovdb/resample.js.map +1 -0
- package/dist/tools/nanovdb/serialize.d.ts +145 -0
- package/dist/tools/nanovdb/serialize.js +395 -0
- package/dist/tools/nanovdb/serialize.js.map +1 -0
- package/dist/tools/nanovdb/stats.d.ts +58 -0
- package/dist/tools/nanovdb/stats.js +149 -0
- package/dist/tools/nanovdb/stats.js.map +1 -0
- package/dist/tools/nanovdb/transform.d.ts +26 -0
- package/dist/tools/nanovdb/transform.js +91 -0
- package/dist/tools/nanovdb/transform.js.map +1 -0
- package/dist/tools/nanovdb/tree.d.ts +175 -0
- package/dist/tools/nanovdb/tree.js +518 -0
- package/dist/tools/nanovdb/tree.js.map +1 -0
- package/dist/tools/nanovdb/write-nvdb.d.ts +39 -0
- package/dist/tools/nanovdb/write-nvdb.js +210 -0
- package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
- package/dist/tools/nvdb-file.d.ts +195 -0
- package/dist/tools/nvdb-file.js +606 -0
- package/dist/tools/nvdb-file.js.map +1 -0
- package/dist/tools/nvdb-stream.d.ts +138 -0
- package/dist/tools/nvdb-stream.js +365 -0
- package/dist/tools/nvdb-stream.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.d.ts +56 -0
- package/dist/tools/vdb/blosc.js +231 -0
- package/dist/tools/vdb/blosc.js.map +1 -0
- package/dist/tools/vdb/byte-reader.d.ts +40 -0
- package/dist/tools/vdb/byte-reader.js +139 -0
- package/dist/tools/vdb/byte-reader.js.map +1 -0
- package/dist/tools/vdb/compression.d.ts +73 -0
- package/dist/tools/vdb/compression.js +249 -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 +147 -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 +3 -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/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 +25 -0
- package/dist/tools/vdb/parse.js +171 -0
- package/dist/tools/vdb/parse.js.map +1 -0
- package/dist/tools/vdb/point-render-data.d.ts +31 -0
- package/dist/tools/vdb/point-render-data.js +57 -0
- package/dist/tools/vdb/point-render-data.js.map +1 -0
- package/dist/tools/vdb/points.d.ts +160 -0
- package/dist/tools/vdb/points.js +794 -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 +138 -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 +116 -0
- package/dist/tools/wvdb/bake.js +311 -0
- package/dist/tools/wvdb/bake.js.map +1 -0
- package/dist/tools/wvdb/dense.d.ts +112 -0
- package/dist/tools/wvdb/dense.js +309 -0
- package/dist/tools/wvdb/dense.js.map +1 -0
- package/dist/tools/wvdb/format.d.ts +161 -0
- package/dist/tools/wvdb/format.js +303 -0
- package/dist/tools/wvdb/format.js.map +1 -0
- package/dist/tools/wvdb/index.d.ts +13 -0
- package/dist/tools/wvdb/index.js +14 -0
- package/dist/tools/wvdb/index.js.map +1 -0
- package/dist/tools/wvdb/level-set.d.ts +48 -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 +54 -0
- package/dist/tools/wvdb/nanovdb.js +60 -0
- package/dist/tools/wvdb/nanovdb.js.map +1 -0
- package/dist/tools/wvdb/read.d.ts +260 -0
- package/dist/tools/wvdb/read.js +743 -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 +127 -0
- package/dist/tools/wvdb/write.js +396 -0
- package/dist/tools/wvdb/write.js.map +1 -0
- package/package.json +82 -4
- package/vendor/LICENSE +201 -0
- package/vendor/NOTICE +19 -0
- package/vendor/VENDOR.md +85 -0
- package/vendor/pnanovdb.wgsl +1539 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* build-from-vdb.ts — bridges the `.vdb` parser to the NanoVDB serializer.
|
|
3
|
+
*
|
|
4
|
+
* A parsed {@link VdbGrid} exposes `iterLeaves()` (each leaf: 8-aligned origin,
|
|
5
|
+
* 512 values, 512-bit value mask), `iterTiles()` (active tiles above leaf
|
|
6
|
+
* level) and an index->world transform. `buildFromVdb` streams those leaves
|
|
7
|
+
* straight into the leaf-iterator build path ({@link vdbBuildFromLeavesDetailed})
|
|
8
|
+
* with the FLOAT codec — no dense array is materialised, so a 7M-active-voxel
|
|
9
|
+
* teapot in a large bbox stays sparse — and writes the active tiles as NanoVDB
|
|
10
|
+
* tiles at the same level (K4.1).
|
|
11
|
+
*
|
|
12
|
+
* Vector grids (`vec3s`, and `vec3d`/`vec3i` converted to f32) build a NanoVDB
|
|
13
|
+
* Vec3f grid with the Vec3f leaf codec (K4.2). Point data grids have no NanoVDB
|
|
14
|
+
* build here (use `grid.points()`).
|
|
15
|
+
*
|
|
16
|
+
* The `.vdb` transform is carried into the NanoVDB Map. v1 supports uniform
|
|
17
|
+
* scale + translate only (which is what all four openvdb.org samples use); a
|
|
18
|
+
* non-uniform scale, rotation or shear throws clearly (GPU resampling is the
|
|
19
|
+
* roadmap for those).
|
|
20
|
+
*/
|
|
21
|
+
import { VDBToolsError, VDBUnsupportedError } from "../errors.js";
|
|
22
|
+
import { VDB_FLOAT_LEAF_CODEC, VDB_VEC3F_LEAF_CODEC } from "./leaf-codec.js";
|
|
23
|
+
import { vdbBuildFromLeavesDetailed, } from "./serialize.js";
|
|
24
|
+
/** Builds a NanoVDB grid image (FLOAT, or Vec3f for vector grids) from a parsed `.vdb` grid. */
|
|
25
|
+
export function buildFromVdb(grid, opts = {}) {
|
|
26
|
+
return buildFromVdbDetailed(grid, opts).image;
|
|
27
|
+
}
|
|
28
|
+
/** As {@link buildFromVdb}, but returns the computed metadata alongside the image. */
|
|
29
|
+
export function buildFromVdbDetailed(grid, opts = {}) {
|
|
30
|
+
if (grid.valueType === "ptdataidx32") {
|
|
31
|
+
throw new VDBUnsupportedError(`buildFromVdb: grid "${grid.name}" is a point data grid; NanoVDB point output is not implemented (use grid.points())`);
|
|
32
|
+
}
|
|
33
|
+
const { voxelSize, translation } = uniformTransform(grid.transform);
|
|
34
|
+
const buildOpts = {
|
|
35
|
+
voxelSize,
|
|
36
|
+
worldOrigin: translation,
|
|
37
|
+
background: grid.background,
|
|
38
|
+
gridName: opts.gridName ?? grid.name ?? "grid",
|
|
39
|
+
gridClass: opts.gridClass ?? sourceGridClass(grid),
|
|
40
|
+
tiles: allTiles(grid),
|
|
41
|
+
collapse: opts.collapse === true,
|
|
42
|
+
};
|
|
43
|
+
const isVector = grid.valueType === "vec3s" || grid.valueType === "vec3d" || grid.valueType === "vec3i";
|
|
44
|
+
const codec = isVector ? VDB_VEC3F_LEAF_CODEC : VDB_FLOAT_LEAF_CODEC;
|
|
45
|
+
return vdbBuildFromLeavesDetailed(grid.iterLeaves(), codec, buildOpts);
|
|
46
|
+
}
|
|
47
|
+
/** Active tiles, then inactive tiles with a stored value (K4.9). */
|
|
48
|
+
function* allTiles(grid) {
|
|
49
|
+
for (const t of grid.iterTiles())
|
|
50
|
+
yield { origin: t.origin, dim: t.dim, value: t.value, active: true };
|
|
51
|
+
for (const t of (grid.iterInactiveTiles?.() ?? [])) {
|
|
52
|
+
yield { origin: t.origin, dim: t.dim, value: t.value, active: false };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** OpenVDB `GridClass` metadata -> NanoVDB class (CreateNanoGrid's `mapToGridClass`). */
|
|
56
|
+
function sourceGridClass(grid) {
|
|
57
|
+
const gridClass = typeof grid.metadata.class === "string" ? grid.metadata.class.toLowerCase() : "";
|
|
58
|
+
if (gridClass === "level set" || gridClass === "levelset")
|
|
59
|
+
return "LevelSet";
|
|
60
|
+
if (gridClass === "fog volume" || gridClass === "fogvolume")
|
|
61
|
+
return "FogVolume";
|
|
62
|
+
if (gridClass === "staggered")
|
|
63
|
+
return "Staggered";
|
|
64
|
+
return "Unknown";
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Extracts a uniform scale + translation from a parsed `.vdb` transform's
|
|
68
|
+
* row-major 4x4 index->world matrix. Throws (with a pointer to the GPU-resample
|
|
69
|
+
* roadmap) on any rotation, shear or non-uniform scale — the serializer's Map is
|
|
70
|
+
* axis-aligned and uniform-scale in v1.
|
|
71
|
+
*/
|
|
72
|
+
export function uniformTransform(t) {
|
|
73
|
+
const m = t.matrix;
|
|
74
|
+
if (m.length !== 16) {
|
|
75
|
+
throw new VDBToolsError("VDB_BAD_OPTION", `buildFromVdb: expected a 4x4 (16-element) transform matrix, got ${m.length}`);
|
|
76
|
+
}
|
|
77
|
+
const sx = m[0];
|
|
78
|
+
const sy = m[5];
|
|
79
|
+
const sz = m[10];
|
|
80
|
+
// Off-diagonal terms of the linear 3x3 block must vanish (no rotation/shear).
|
|
81
|
+
const offDiagonal = [m[1], m[2], m[4], m[6], m[8], m[9]];
|
|
82
|
+
const eps = 1e-6 * Math.max(1, Math.abs(sx), Math.abs(sy), Math.abs(sz));
|
|
83
|
+
const rotated = offDiagonal.some((v) => Math.abs(v) > eps);
|
|
84
|
+
const nonUniform = Math.abs(sx - sy) > eps || Math.abs(sx - sz) > eps;
|
|
85
|
+
if (rotated || nonUniform) {
|
|
86
|
+
throw new VDBUnsupportedError(`buildFromVdb: transform "${t.type}" is ${rotated ? "rotated/sheared" : "non-uniformly scaled"} ` +
|
|
87
|
+
`(scale [${sx}, ${sy}, ${sz}]${rotated ? `, off-diagonal ${JSON.stringify(offDiagonal)}` : ""}). ` +
|
|
88
|
+
`v1 supports uniform scale + translate only; rotation/shear/anisotropy need GPU resampling (roadmap).`);
|
|
89
|
+
}
|
|
90
|
+
return { voxelSize: sx, translation: [m[3], m[7], m[11]] };
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=build-from-vdb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-from-vdb.js","sourceRoot":"","sources":["../../../src/tools/nanovdb/build-from-vdb.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EACL,0BAA0B,GAI3B,MAAM,gBAAgB,CAAC;AAiBxB,gGAAgG;AAChG,MAAM,UAAU,YAAY,CAAC,IAAa,EAAE,OAA4B,EAAE;IACxE,OAAO,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC;AAChD,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,oBAAoB,CAAC,IAAa,EAAE,OAA4B,EAAE;IAChF,IAAI,IAAI,CAAC,SAAS,KAAK,aAAa,EAAE,CAAC;QACrC,MAAM,IAAI,mBAAmB,CAC3B,uBAAuB,IAAI,CAAC,IAAI,qFAAqF,CACtH,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACpE,MAAM,SAAS,GAA8B;QAC3C,SAAS;QACT,WAAW,EAAE,WAAW;QACxB,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,IAAI,MAAM;QAC9C,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,eAAe,CAAC,IAAI,CAAC;QAClD,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC;QACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,KAAK,IAAI;KACjC,CAAC;IACF,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,KAAK,OAAO,IAAI,IAAI,CAAC,SAAS,KAAK,OAAO,IAAI,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC;IACxG,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,oBAAoB,CAAC;IACrE,OAAO,0BAA0B,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AACzE,CAAC;AAED,oEAAoE;AACpE,QAAQ,CAAC,CAAC,QAAQ,CAAC,IAAa;IAC9B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,SAAS,EAAyB;QAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC9H,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,CAAwB,EAAE,CAAC;QAC1E,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACxE,CAAC;AACH,CAAC;AAED,yFAAyF;AACzF,SAAS,eAAe,CAAC,IAAa;IACpC,MAAM,SAAS,GAAG,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACnG,IAAI,SAAS,KAAK,WAAW,IAAI,SAAS,KAAK,UAAU;QAAE,OAAO,UAAU,CAAC;IAC7E,IAAI,SAAS,KAAK,YAAY,IAAI,SAAS,KAAK,WAAW;QAAE,OAAO,WAAW,CAAC;IAChF,IAAI,SAAS,KAAK,WAAW;QAAE,OAAO,WAAW,CAAC;IAClD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,CAAmB;IAIlD,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,IAAI,CAAC,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;QACpB,MAAM,IAAI,aAAa,CAAC,gBAAgB,EAAE,mEAAmE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3H,CAAC;IACD,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;IACjB,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC;IACjB,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAE,CAAC;IAClB,8EAA8E;IAC9E,MAAM,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC;IAC/D,MAAM,GAAG,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACzE,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IAC3D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC;IACtE,IAAI,OAAO,IAAI,UAAU,EAAE,CAAC;QAC1B,MAAM,IAAI,mBAAmB,CAC3B,4BAA4B,CAAC,CAAC,IAAI,QAAQ,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,sBAAsB,GAAG;YAC/F,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK;YAClG,sGAAsG,CACzG,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,EAAE,CAAE,CAAC,EAAE,CAAC;AAChE,CAAC","sourcesContent":["/**\n * build-from-vdb.ts — bridges the `.vdb` parser to the NanoVDB serializer.\n *\n * A parsed {@link VdbGrid} exposes `iterLeaves()` (each leaf: 8-aligned origin,\n * 512 values, 512-bit value mask), `iterTiles()` (active tiles above leaf\n * level) and an index->world transform. `buildFromVdb` streams those leaves\n * straight into the leaf-iterator build path ({@link vdbBuildFromLeavesDetailed})\n * with the FLOAT codec — no dense array is materialised, so a 7M-active-voxel\n * teapot in a large bbox stays sparse — and writes the active tiles as NanoVDB\n * tiles at the same level (K4.1).\n *\n * Vector grids (`vec3s`, and `vec3d`/`vec3i` converted to f32) build a NanoVDB\n * Vec3f grid with the Vec3f leaf codec (K4.2). Point data grids have no NanoVDB\n * build here (use `grid.points()`).\n *\n * The `.vdb` transform is carried into the NanoVDB Map. v1 supports uniform\n * scale + translate only (which is what all four openvdb.org samples use); a\n * non-uniform scale, rotation or shear throws clearly (GPU resampling is the\n * roadmap for those).\n */\n\nimport { VDBToolsError, VDBUnsupportedError } from \"../errors.js\";\nimport type { VdbGrid, VdbTransformInfo } from \"../vdb/types.js\";\nimport type { TileInput } from \"./tree.js\";\nimport { VDB_FLOAT_LEAF_CODEC, VDB_VEC3F_LEAF_CODEC } from \"./leaf-codec.js\";\nimport {\n vdbBuildFromLeavesDetailed,\n type VDBBuildFromLeavesOptions,\n type VDBBuiltGrid,\n type GridClassName,\n} from \"./serialize.js\";\n\nexport interface BuildFromVdbOptions {\n /** Grid name for the output image. Default: the source grid's name (or \"grid\"). */\n gridName?: string;\n /** Grid class. Default: mapped from source metadata. */\n gridClass?: GridClassName;\n /**\n * Collapse uniform leaves and nodes into tiles (OpenVDB `prune`, tolerance 0;\n * K4.6). Default false: `nanovdb_convert` (CreateNanoGrid) copies the OpenVDB\n * tree as it is, and so do we, so our image of a `.vdb` keeps native's\n * topology (the parity fixtures). Files written by OpenVDB tools are usually\n * pruned already.\n */\n collapse?: boolean;\n}\n\n/** Builds a NanoVDB grid image (FLOAT, or Vec3f for vector grids) from a parsed `.vdb` grid. */\nexport function buildFromVdb(grid: VdbGrid, opts: BuildFromVdbOptions = {}): Uint32Array {\n return buildFromVdbDetailed(grid, opts).image;\n}\n\n/** As {@link buildFromVdb}, but returns the computed metadata alongside the image. */\nexport function buildFromVdbDetailed(grid: VdbGrid, opts: BuildFromVdbOptions = {}): VDBBuiltGrid {\n if (grid.valueType === \"ptdataidx32\") {\n throw new VDBUnsupportedError(\n `buildFromVdb: grid \"${grid.name}\" is a point data grid; NanoVDB point output is not implemented (use grid.points())`,\n );\n }\n const { voxelSize, translation } = uniformTransform(grid.transform);\n const buildOpts: VDBBuildFromLeavesOptions = {\n voxelSize,\n worldOrigin: translation,\n background: grid.background,\n gridName: opts.gridName ?? grid.name ?? \"grid\",\n gridClass: opts.gridClass ?? sourceGridClass(grid),\n tiles: allTiles(grid),\n collapse: opts.collapse === true,\n };\n const isVector = grid.valueType === \"vec3s\" || grid.valueType === \"vec3d\" || grid.valueType === \"vec3i\";\n const codec = isVector ? VDB_VEC3F_LEAF_CODEC : VDB_FLOAT_LEAF_CODEC;\n return vdbBuildFromLeavesDetailed(grid.iterLeaves(), codec, buildOpts);\n}\n\n/** Active tiles, then inactive tiles with a stored value (K4.9). */\nfunction* allTiles(grid: VdbGrid): Generator<TileInput> {\n for (const t of grid.iterTiles() as Iterable<TileInput>) yield { origin: t.origin, dim: t.dim, value: t.value, active: true };\n for (const t of (grid.iterInactiveTiles?.() ?? []) as Iterable<TileInput>) {\n yield { origin: t.origin, dim: t.dim, value: t.value, active: false };\n }\n}\n\n/** OpenVDB `GridClass` metadata -> NanoVDB class (CreateNanoGrid's `mapToGridClass`). */\nfunction sourceGridClass(grid: VdbGrid): GridClassName {\n const gridClass = typeof grid.metadata.class === \"string\" ? grid.metadata.class.toLowerCase() : \"\";\n if (gridClass === \"level set\" || gridClass === \"levelset\") return \"LevelSet\";\n if (gridClass === \"fog volume\" || gridClass === \"fogvolume\") return \"FogVolume\";\n if (gridClass === \"staggered\") return \"Staggered\";\n return \"Unknown\";\n}\n\n/**\n * Extracts a uniform scale + translation from a parsed `.vdb` transform's\n * row-major 4x4 index->world matrix. Throws (with a pointer to the GPU-resample\n * roadmap) on any rotation, shear or non-uniform scale — the serializer's Map is\n * axis-aligned and uniform-scale in v1.\n */\nexport function uniformTransform(t: VdbTransformInfo): {\n voxelSize: number;\n translation: [number, number, number];\n} {\n const m = t.matrix;\n if (m.length !== 16) {\n throw new VDBToolsError(\"VDB_BAD_OPTION\", `buildFromVdb: expected a 4x4 (16-element) transform matrix, got ${m.length}`);\n }\n const sx = m[0]!;\n const sy = m[5]!;\n const sz = m[10]!;\n // Off-diagonal terms of the linear 3x3 block must vanish (no rotation/shear).\n const offDiagonal = [m[1]!, m[2]!, m[4]!, m[6]!, m[8]!, m[9]!];\n const eps = 1e-6 * Math.max(1, Math.abs(sx), Math.abs(sy), Math.abs(sz));\n const rotated = offDiagonal.some((v) => Math.abs(v) > eps);\n const nonUniform = Math.abs(sx - sy) > eps || Math.abs(sx - sz) > eps;\n if (rotated || nonUniform) {\n throw new VDBUnsupportedError(\n `buildFromVdb: transform \"${t.type}\" is ${rotated ? \"rotated/sheared\" : \"non-uniformly scaled\"} ` +\n `(scale [${sx}, ${sy}, ${sz}]${rotated ? `, off-diagonal ${JSON.stringify(offDiagonal)}` : \"\"}). ` +\n `v1 supports uniform scale + translate only; rotation/shear/anisotropy need GPU resampling (roadmap).`,\n );\n }\n return { voxelSize: sx, translation: [m[3]!, m[7]!, m[11]!] };\n}\n"]}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bytes.ts — the single home for every NanoVDB struct offset/size constant and
|
|
3
|
+
* the low-level little-endian writer used by the serializer. No other module in
|
|
4
|
+
* `nanovdb/` writes a raw byte offset: they go through the named constants and
|
|
5
|
+
* the {@link GridImageWriter} helpers here.
|
|
6
|
+
*
|
|
7
|
+
* ## Provenance of the numbers
|
|
8
|
+
*
|
|
9
|
+
* Every constant below is the ABI-32.9.1 value extracted into
|
|
10
|
+
* `packages/vdb/vendor/stride-tables.json` (itself generated from the
|
|
11
|
+
* vendored `PNanoVDB.h`). They are duplicated here as named literals rather than
|
|
12
|
+
* read from that JSON at runtime on purpose: `@pmndrs/vdb/tools` is the pure-TS,
|
|
13
|
+
* browser-first CPU half (decision D3) and must not pull in `node:fs`. To keep
|
|
14
|
+
* the two provably in lockstep, `test/bytes-constants.test.ts` reads
|
|
15
|
+
* stride-tables.json and asserts each constant here equals the extracted value.
|
|
16
|
+
*
|
|
17
|
+
* Only the FLOAT grid type is wired up in this wave; the per-grid-type layout
|
|
18
|
+
* (`FLOAT` block below) is isolated so Fp8/FpN can be added as sibling blocks in
|
|
19
|
+
* the quantization wave without touching the common offsets.
|
|
20
|
+
*/
|
|
21
|
+
/** Grid-image magic `NanoVDB1` (u64, little-endian). This is what the raw grid
|
|
22
|
+
* buffer starts with — what `readValue`/`NvdbFile` sniff for. */
|
|
23
|
+
export declare const MAGIC_GRID = 3549474594348753230n;
|
|
24
|
+
/** File-header magic `NanoVDB2` (u64) for the segment `.nvdb` container. */
|
|
25
|
+
export declare const MAGIC_FILE = 3621532188386681166n;
|
|
26
|
+
export declare const MAJOR_VERSION = 32;
|
|
27
|
+
export declare const MINOR_VERSION = 9;
|
|
28
|
+
export declare const PATCH_VERSION = 1;
|
|
29
|
+
/** Packed `Version`: major<<21 | minor<<10 | patch. */
|
|
30
|
+
export declare const VERSION_PACKED: number;
|
|
31
|
+
export declare const GRID_TYPE_FLOAT = 1;
|
|
32
|
+
export declare const GRID_TYPE_FP4 = 13;
|
|
33
|
+
export declare const GRID_TYPE_FP8 = 14;
|
|
34
|
+
export declare const GRID_TYPE_FP16 = 15;
|
|
35
|
+
export declare const GRID_TYPE_FPN = 16;
|
|
36
|
+
export declare const GRID_TYPE_VEC3F = 6;
|
|
37
|
+
export declare const GRID_CLASS_UNKNOWN = 0;
|
|
38
|
+
export declare const GRID_CLASS_LEVEL_SET = 1;
|
|
39
|
+
export declare const GRID_CLASS_FOG_VOLUME = 2;
|
|
40
|
+
export declare const GRID_CLASS_STAGGERED = 3;
|
|
41
|
+
/**
|
|
42
|
+
* GridData.mFlags for a grid that carries a bbox and full min/max/ave/stddev
|
|
43
|
+
* statistics and is laid out breadth-first — the exact value native
|
|
44
|
+
* `nanovdb_convert` writes for a stats-bearing float FogVolume (verified:
|
|
45
|
+
* `sphere_fog_float.nvdb` carries 0x3e). Bit0 (HasLongGridName) stays clear
|
|
46
|
+
* because we reject names longer than the inline 256-byte field.
|
|
47
|
+
* bit1 HasBBox | bit2 HasMinMax | bit3 HasAverage | bit4 HasStdDeviation |
|
|
48
|
+
* bit5 IsBreadthFirst
|
|
49
|
+
*/
|
|
50
|
+
export declare const GRID_FLAGS_STATS_BBOX_BREADTH_FIRST = 62;
|
|
51
|
+
/**
|
|
52
|
+
* Internal-node (`mFlags`, u64) and leaf (`bbox_dif_and_flags` high byte) flag
|
|
53
|
+
* value written by native `nanovdb_convert` on every stats-bearing node
|
|
54
|
+
* (verified: uppers, lowers and leaves in `sphere_fog_float.nvdb` all carry 2).
|
|
55
|
+
* Neither the CPU (`read-value.ts`) nor WGSL FLOAT readers consult it; we mirror
|
|
56
|
+
* it for structural fidelity with native output.
|
|
57
|
+
*/
|
|
58
|
+
export declare const NODE_FLAG_STATS = 2;
|
|
59
|
+
export declare const GRID_SIZE = 672;
|
|
60
|
+
export declare const GRID_OFF_MAGIC = 0;
|
|
61
|
+
export declare const GRID_OFF_CHECKSUM = 8;
|
|
62
|
+
export declare const GRID_OFF_VERSION = 16;
|
|
63
|
+
export declare const GRID_OFF_FLAGS = 20;
|
|
64
|
+
export declare const GRID_OFF_GRID_INDEX = 24;
|
|
65
|
+
export declare const GRID_OFF_GRID_COUNT = 28;
|
|
66
|
+
export declare const GRID_OFF_GRID_SIZE = 32;
|
|
67
|
+
export declare const GRID_OFF_GRID_NAME = 40;
|
|
68
|
+
export declare const GRID_NAME_MAX = 256;
|
|
69
|
+
export declare const GRID_OFF_MAP = 296;
|
|
70
|
+
export declare const GRID_OFF_WORLD_BBOX = 560;
|
|
71
|
+
export declare const GRID_OFF_VOXEL_SIZE = 608;
|
|
72
|
+
export declare const GRID_OFF_GRID_CLASS = 632;
|
|
73
|
+
export declare const GRID_OFF_GRID_TYPE = 636;
|
|
74
|
+
export declare const GRID_OFF_BLIND_METADATA_OFFSET = 640;
|
|
75
|
+
export declare const GRID_OFF_BLIND_METADATA_COUNT = 648;
|
|
76
|
+
export declare const GRID_OFF_DATA0 = 652;
|
|
77
|
+
export declare const GRID_OFF_DATA1 = 656;
|
|
78
|
+
export declare const GRID_OFF_DATA2 = 664;
|
|
79
|
+
/**
|
|
80
|
+
* GridData.mChecksum sentinel meaning "no checksum" (NanoVDB `ChecksumMode`
|
|
81
|
+
* Disable == ~uint64_t(0)). We write this rather than a real CRC: neither the
|
|
82
|
+
* CPU reader, the WGSL reader, nor `NvdbFile.fromArrayBuffer` validates the
|
|
83
|
+
* checksum (verified by reading their source — only magic, version and
|
|
84
|
+
* mGridSize are cross-checked), so a disabled checksum round-trips cleanly.
|
|
85
|
+
* Computing the native CRC48/Full checksum is deferred to the nanovdb_convert
|
|
86
|
+
* byte-parity item (see build-from-dense.ts module doc).
|
|
87
|
+
*/
|
|
88
|
+
export declare const CHECKSUM_DISABLED = 18446744073709551615n;
|
|
89
|
+
export declare const MAP_OFF_MATF = 0;
|
|
90
|
+
export declare const MAP_OFF_INVMATF = 36;
|
|
91
|
+
export declare const MAP_OFF_VECF = 72;
|
|
92
|
+
export declare const MAP_OFF_TAPERF = 84;
|
|
93
|
+
export declare const MAP_OFF_MATD = 88;
|
|
94
|
+
export declare const MAP_OFF_INVMATD = 160;
|
|
95
|
+
export declare const MAP_OFF_VECD = 232;
|
|
96
|
+
export declare const MAP_OFF_TAPERD = 256;
|
|
97
|
+
export declare const MAP_SIZE = 264;
|
|
98
|
+
export declare const TREE_SIZE = 64;
|
|
99
|
+
export declare const TREE_OFF_NODE_OFFSET_LEAF = 0;
|
|
100
|
+
export declare const TREE_OFF_NODE_OFFSET_LOWER = 8;
|
|
101
|
+
export declare const TREE_OFF_NODE_OFFSET_UPPER = 16;
|
|
102
|
+
export declare const TREE_OFF_NODE_OFFSET_ROOT = 24;
|
|
103
|
+
export declare const TREE_OFF_NODE_COUNT_LEAF = 32;
|
|
104
|
+
export declare const TREE_OFF_NODE_COUNT_LOWER = 36;
|
|
105
|
+
export declare const TREE_OFF_NODE_COUNT_UPPER = 40;
|
|
106
|
+
export declare const TREE_OFF_TILE_COUNT_LOWER = 44;
|
|
107
|
+
export declare const TREE_OFF_TILE_COUNT_UPPER = 48;
|
|
108
|
+
export declare const TREE_OFF_TILE_COUNT_ROOT = 52;
|
|
109
|
+
export declare const TREE_OFF_VOXEL_COUNT = 56;
|
|
110
|
+
export declare const ROOT_OFF_BBOX_MIN = 0;
|
|
111
|
+
export declare const ROOT_OFF_BBOX_MAX = 12;
|
|
112
|
+
export declare const ROOT_OFF_TABLE_SIZE = 24;
|
|
113
|
+
export declare const ROOT_TILE_OFF_KEY = 0;
|
|
114
|
+
export declare const ROOT_TILE_OFF_CHILD = 8;
|
|
115
|
+
export declare const ROOT_TILE_OFF_STATE = 16;
|
|
116
|
+
export declare const NODE_OFF_BBOX_MIN = 0;
|
|
117
|
+
export declare const NODE_OFF_BBOX_MAX = 12;
|
|
118
|
+
export declare const NODE_OFF_FLAGS = 24;
|
|
119
|
+
export declare const NODE_OFF_VALUE_MASK = 32;
|
|
120
|
+
export declare const UPPER_OFF_CHILD_MASK = 4128;
|
|
121
|
+
export declare const UPPER_TABLE_COUNT = 32768;
|
|
122
|
+
export declare const LOWER_OFF_CHILD_MASK = 544;
|
|
123
|
+
export declare const LOWER_TABLE_COUNT = 4096;
|
|
124
|
+
export declare const LEAF_OFF_BBOX_MIN = 0;
|
|
125
|
+
export declare const LEAF_OFF_BBOX_DIF_AND_FLAGS = 12;
|
|
126
|
+
export declare const LEAF_OFF_VALUE_MASK = 16;
|
|
127
|
+
export declare const LEAF_TABLE_COUNT = 512;
|
|
128
|
+
export declare const LEAF_OFF_FP_MINIMUM = 80;
|
|
129
|
+
export declare const LEAF_OFF_FP_QUANTUM = 84;
|
|
130
|
+
export declare const LEAF_OFF_FP_STAT_MIN = 88;
|
|
131
|
+
export declare const LEAF_OFF_FP_STAT_MAX = 90;
|
|
132
|
+
export declare const LEAF_OFF_FP_STAT_AVG = 92;
|
|
133
|
+
export declare const LEAF_OFF_FP_STAT_DEV = 94;
|
|
134
|
+
export declare const LEAF_OFF_FP_CODES = 96;
|
|
135
|
+
export declare const FP_LEAF_HEADER_SIZE = 96;
|
|
136
|
+
/** FpN leaf `mFlags` (high byte of bbox_dif_and_flags): logBitWidth in bits 5-7,
|
|
137
|
+
* plus the has-bbox bit the native encoder always sets (0x02). Fp8 uses 0x02. */
|
|
138
|
+
export declare const LEAF_FLAG_HAS_BBOX = 2;
|
|
139
|
+
/** Per-grid-type node sizes, stat offsets and table geometry (ABI 32.9.1). */
|
|
140
|
+
export interface GridTypeLayout {
|
|
141
|
+
readonly gridType: number;
|
|
142
|
+
readonly rootSize: number;
|
|
143
|
+
readonly rootTileSize: number;
|
|
144
|
+
readonly rootTileOffValue: number;
|
|
145
|
+
readonly rootOffBackground: number;
|
|
146
|
+
readonly rootOffMin: number;
|
|
147
|
+
readonly rootOffMax: number;
|
|
148
|
+
readonly rootOffAve: number;
|
|
149
|
+
readonly rootOffStdDev: number;
|
|
150
|
+
readonly tableStride: number;
|
|
151
|
+
readonly valueStrideBits: number;
|
|
152
|
+
readonly upperSize: number;
|
|
153
|
+
readonly upperOffTable: number;
|
|
154
|
+
readonly upperOffMin: number;
|
|
155
|
+
readonly upperOffMax: number;
|
|
156
|
+
readonly upperOffAve: number;
|
|
157
|
+
readonly upperOffStdDev: number;
|
|
158
|
+
readonly lowerSize: number;
|
|
159
|
+
readonly lowerOffTable: number;
|
|
160
|
+
readonly lowerOffMin: number;
|
|
161
|
+
readonly lowerOffMax: number;
|
|
162
|
+
readonly lowerOffAve: number;
|
|
163
|
+
readonly lowerOffStdDev: number;
|
|
164
|
+
readonly leafSize: number;
|
|
165
|
+
readonly leafOffTable: number;
|
|
166
|
+
readonly leafOffMin: number;
|
|
167
|
+
readonly leafOffMax: number;
|
|
168
|
+
readonly leafOffAve: number;
|
|
169
|
+
readonly leafOffStdDev: number;
|
|
170
|
+
}
|
|
171
|
+
export declare const FLOAT_LAYOUT: GridTypeLayout;
|
|
172
|
+
/** Fp8: fixed 8-bit codes. Leaf = 96-byte header + 512 bytes = 608. */
|
|
173
|
+
export declare const FP8_LAYOUT: GridTypeLayout;
|
|
174
|
+
/** Fp4: fixed 4-bit codes. Leaf = 96-byte header + 256 bytes = 352. */
|
|
175
|
+
export declare const FP4_LAYOUT: GridTypeLayout;
|
|
176
|
+
/** Fp16: fixed 16-bit codes. Leaf = 96-byte header + 1024 bytes = 1120. */
|
|
177
|
+
export declare const FP16_LAYOUT: GridTypeLayout;
|
|
178
|
+
/** FpN: variable bit-width. `leafSize` is the 96-byte base (see codec). */
|
|
179
|
+
export declare const FPN_LAYOUT: GridTypeLayout;
|
|
180
|
+
/**
|
|
181
|
+
* Vec3f (K4.2): every value is 3 f32 (12 bytes); `mMinimum`/`mMaximum` are
|
|
182
|
+
* Vec3f and `mAverage`/`mStdDevi` stay f32 (`FloatTraits<Vec3f>` is float).
|
|
183
|
+
* Internal-node table slots are 16 bytes (the union of a 12-byte value and an
|
|
184
|
+
* i64 child offset); the leaf table is 32-byte aligned at 128. Values from
|
|
185
|
+
* `PNANOVDB_GRID_TYPE_VEC3F` in the vendored stride tables.
|
|
186
|
+
*/
|
|
187
|
+
export declare const VEC3F_LAYOUT: GridTypeLayout;
|
|
188
|
+
/** pnanovdb_coord_to_key — root-tile key for a voxel coord (native-64 branch). */
|
|
189
|
+
export declare function coordToKey(x: number, y: number, z: number): bigint;
|
|
190
|
+
/** pnanovdb_upper_coord_to_offset — lower-table slot within a 32^3 upper. */
|
|
191
|
+
export declare function upperCoordToOffset(x: number, y: number, z: number): number;
|
|
192
|
+
/** pnanovdb_lower_coord_to_offset — leaf-table slot within a 16^3 lower. */
|
|
193
|
+
export declare function lowerCoordToOffset(x: number, y: number, z: number): number;
|
|
194
|
+
/** pnanovdb_leaf_coord_to_offset — voxel slot within an 8^3 leaf, 0..511. */
|
|
195
|
+
export declare function leafCoordToOffset(x: number, y: number, z: number): number;
|
|
196
|
+
/**
|
|
197
|
+
* A thin, endianness-explicit writer over a single grid image's backing
|
|
198
|
+
* `ArrayBuffer`. All NanoVDB integers/floats are little-endian; every setter
|
|
199
|
+
* here passes `true` so the code never repeats the flag. Mask helpers implement
|
|
200
|
+
* `pnanovdb_*_mask` bit addressing (32-bit words, LSB-first within a word).
|
|
201
|
+
*/
|
|
202
|
+
export declare class GridImageWriter {
|
|
203
|
+
readonly bytes: Uint8Array;
|
|
204
|
+
readonly u32: Uint32Array;
|
|
205
|
+
private readonly view;
|
|
206
|
+
constructor(byteLength: number);
|
|
207
|
+
setU16(off: number, v: number): void;
|
|
208
|
+
setU32(off: number, v: number): void;
|
|
209
|
+
setI32(off: number, v: number): void;
|
|
210
|
+
setU64(off: number, v: bigint): void;
|
|
211
|
+
setI64(off: number, v: bigint): void;
|
|
212
|
+
setF32(off: number, v: number): void;
|
|
213
|
+
setF64(off: number, v: number): void;
|
|
214
|
+
/** Writes `len` bytes of `src` at `off`, zero-filling nothing beyond it. */
|
|
215
|
+
setBytes(off: number, src: Uint8Array): void;
|
|
216
|
+
/** Sets bit `bitIndex` of a mask word array whose word 0 starts at `maskBase`. */
|
|
217
|
+
setMaskBit(maskBase: number, bitIndex: number): void;
|
|
218
|
+
/** Copies a whole precomputed 32-bit mask (`words` u32s) to `maskBase`. */
|
|
219
|
+
setMaskWords(maskBase: number, words: Uint32Array): void;
|
|
220
|
+
}
|