@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 @@
|
|
|
1
|
+
{"version":3,"file":"value-transform.js","sourceRoot":"","sources":["../../../src/core/compute/value-transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAKjE,uEAAuE;AACvE,MAAM,CAAC,MAAM,2BAA2B,GAAkF,MAAM,CAAC,MAAM,CAAC;IACtI,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC;IAC5B,IAAI,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG;IAC5B,MAAM,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC;IACzB,OAAO,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;CACpD,CAAC,CAAC;AAIH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,sBAAsB,CACpC,IAAiB,EACjB,MAAc,EACd,WAAwB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value edits for pool grids (K2.3).\n *\n * Decided for 0.1: the transform runs on the CPU (`transformLeafValues` in\n * `@pmndrs/vdb/tools`) and the result is staged with `pool.replace`. v1 ran a\n * WGSL body on the GPU against a `read_write` copy of the image; the pool binds\n * read-only to every module (D10) and keeps no CPU copy of an image, so the\n * host passes the source image it added.\n *\n * A GPU write path may follow if interactive use needs it (demo 04 on the\n * reference device is the test): copy the image range into a scratch buffer,\n * run the transform with its own `read_write` binding, then a core\n * `pool.replaceFromBuffer(id, buffer, offset)` that copies GPU to GPU in\n * `update`.\n */\nimport { VDBError } from \"../errors.js\";\nimport type { VDBGridPool } from \"../pool/pool.js\";\nimport { transformLeafValues } from \"../../tools/cpu/compute.js\";\n\n/** A per-value function; the result is rounded to f32. */\nexport type VDBValueTransform = (value: number) => number;\n\n/** Named transforms (v1's `VALUE_TRANSFORM_PRESETS`, as functions). */\nexport const VDB_VALUE_TRANSFORM_PRESETS: Readonly<Record<\"double\" | \"half\" | \"negate\" | \"clamp01\", VDBValueTransform>> = Object.freeze({\n double: (v: number) => v * 2,\n half: (v: number) => v * 0.5,\n negate: (v: number) => -v,\n clamp01: (v: number) => Math.min(Math.max(v, 0), 1),\n});\n\nexport type VDBValueTransformPreset = keyof typeof VDB_VALUE_TRANSFORM_PRESETS;\n\n/**\n * Applies `transform` (a function or a preset name) to every leaf voxel value\n * inside grid `gridId`'s index bbox, and stages the result with\n * `pool.replace(gridId, image)`. Returns the new image (the source is not\n * modified); it reaches the GPU at the next `pool.update` / `pool.flush`, in\n * place (same size, so no `version` change).\n *\n * `sourceImage` is the grid's current image (the pool keeps none); it must be\n * the grid in the pool, which is checked by type, byte size and index bbox.\n *\n * As in v1: Float grids only; tile and background values are not changed;\n * the image's statistics are not recomputed (they keep describing the source\n * values, so `gridStats` bins against the old range and `vdbNodeMax` bounds\n * may be stale). Like `replace`, the pool holds the returned array until\n * `settled()`; don't reuse it before then.\n */\nexport function vdbApplyValueTransform(\n pool: VDBGridPool,\n gridId: number,\n sourceImage: Uint32Array,\n transform: VDBValueTransform | VDBValueTransformPreset,\n): Uint32Array {\n const where = \"vdbApplyValueTransform\";\n const fn = typeof transform === \"string\" ? VDB_VALUE_TRANSFORM_PRESETS[transform] : transform;\n if (typeof fn !== \"function\") {\n throw new VDBError(\n \"VDB_BAD_OPTION\",\n `${where}: transform must be a function (v) => number or one of ${Object.keys(VDB_VALUE_TRANSFORM_PRESETS).join(\", \")}; got ${JSON.stringify(transform)}.`,\n );\n }\n const info = pool.info(gridId);\n if (info.type !== \"float\") {\n throw new VDBError(\n \"VDB_UNSUPPORTED_GRID_TYPE\",\n `${where}: grid ${gridId} is ${info.type}; value transforms need a Float grid (quantized leaves would need re-encoding). Transform the Float source, quantize() it, and pool.replace().`,\n );\n }\n if (!(sourceImage instanceof Uint32Array) || sourceImage.byteLength !== info.imageBytes) {\n throw new VDBError(\n \"VDB_BAD_OPTION\",\n `${where}: sourceImage must be grid ${gridId}'s current image (${info.imageBytes} bytes); got ${sourceImage instanceof Uint32Array ? `${sourceImage.byteLength} bytes` : typeof sourceImage}.`,\n );\n }\n const image = transformLeafValues(sourceImage, fn);\n pool.replace(gridId, image);\n return image;\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error type for the engine-free core (docs/dev/design/K1-core.md §4).
|
|
3
|
+
* Every message should say what to do next.
|
|
4
|
+
*/
|
|
5
|
+
export type VDBErrorCode = "VDB_UNSUPPORTED_DEVICE" | "VDB_BAD_IMAGE" | "VDB_UNSUPPORTED_GRID_TYPE" | "VDB_POOL_LIMIT" | "VDB_POOL_FULL" | "VDB_UNKNOWN_GRID" | "VDB_NO_STATS" | "VDB_TYPE_NOT_COMPILED" | "VDB_LAYOUT_MISMATCH" | "VDB_BAD_OPTION" | "VDB_DISPOSED"
|
|
6
|
+
/** An engine adapter found the engine's internals not behaving as the adapter expects (e.g. a renderer version it wasn't built for). */
|
|
7
|
+
| "VDB_ENGINE_MISMATCH";
|
|
8
|
+
export declare class VDBError extends Error {
|
|
9
|
+
readonly code: VDBErrorCode;
|
|
10
|
+
constructor(code: VDBErrorCode, message: string);
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/core/errors.ts"],"names":[],"mappings":"AAmBA,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,IAAI,CAAe;IAE5B,YAAY,IAAkB,EAAE,OAAe;QAC7C,KAAK,CAAC,gBAAgB,IAAI,MAAM,OAAO,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF","sourcesContent":["/**\n * Error type for the engine-free core (docs/dev/design/K1-core.md §4).\n * Every message should say what to do next.\n */\nexport type VDBErrorCode =\n | \"VDB_UNSUPPORTED_DEVICE\"\n | \"VDB_BAD_IMAGE\"\n | \"VDB_UNSUPPORTED_GRID_TYPE\"\n | \"VDB_POOL_LIMIT\"\n | \"VDB_POOL_FULL\"\n | \"VDB_UNKNOWN_GRID\"\n | \"VDB_NO_STATS\"\n | \"VDB_TYPE_NOT_COMPILED\"\n | \"VDB_LAYOUT_MISMATCH\"\n | \"VDB_BAD_OPTION\"\n | \"VDB_DISPOSED\"\n /** An engine adapter found the engine's internals not behaving as the adapter expects (e.g. a renderer version it wasn't built for). */\n | \"VDB_ENGINE_MISMATCH\";\n\nexport class VDBError extends Error {\n readonly code: VDBErrorCode;\n\n constructor(code: VDBErrorCode, message: string) {\n super(`@pmndrs/vdb [${code}]: ${message}`);\n this.name = \"VDBError\";\n this.code = code;\n }\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @pmndrs/vdb (core) - the engine-free WebGPU core: a pool of NanoVDB grids in one storage buffer,
|
|
3
|
+
* the generated `vdb*` WGSL module that reads it, and compute tools that run on it.
|
|
4
|
+
*
|
|
5
|
+
* Everything usable without a GPU (the `.nvdb` loader, the CPU oracle, the `.vdb` tooling) lives in
|
|
6
|
+
* `@pmndrs/vdb/tools`. The core never imports `three` (test/boundaries.test.ts).
|
|
7
|
+
*
|
|
8
|
+
* This barrel is the public API (D32). The pool's binary layout helpers and other test oracles live in
|
|
9
|
+
* `./internal.ts`, imported by path by tests and harnesses; it is not a package export.
|
|
10
|
+
*/
|
|
11
|
+
/// <reference types="@webgpu/types" preserve="true" />
|
|
12
|
+
export { VDBError } from "./errors.js";
|
|
13
|
+
export type { VDBErrorCode } from "./errors.js";
|
|
14
|
+
export { VDBGridPool } from "./pool/pool.js";
|
|
15
|
+
export type { VDBAddOptions, VDBBrickMajorant, VDBGridInfo, VDBGridPoolOptions, VDBTransformInput, } from "./pool/pool.js";
|
|
16
|
+
/** The pool's GPU layout version, for `vdbCheckModule({ layoutVersion })`. */
|
|
17
|
+
export { VDB_GPU_LAYOUT_VERSION } from "./pool/layout.js";
|
|
18
|
+
export type { VDBVec3 } from "./pool/layout.js";
|
|
19
|
+
export { vdbCheckModule, vdbModuleEntries, vdbModuleWgsl } from "./wgsl/generate.js";
|
|
20
|
+
export type { VDBBufferModuleOptions, VDBModuleCommonOptions, VDBModuleHelper, VDBModuleOptions, VDBModulePoolLike, VDBModuleProfile, VDBModuleTypeCheck, VDBSlotModuleOptions, } from "./wgsl/types.js";
|
|
21
|
+
export { VDB_ALL_SCALAR_TYPES, VDB_GRID_TYPE_IDS, VDB_GRID_TYPE_NAMES } from "./types.js";
|
|
22
|
+
export type { VDBGridTypeName, VDBSlot } from "./types.js";
|
|
23
|
+
export { vdbApplyValueTransform, vdbDecodeToAtlasGpu, vdbGridStatsGpu, VDB_VALUE_TRANSFORM_PRESETS } from "./compute/index.js";
|
|
24
|
+
export { vdbCreateBoxPyramid } from "./compute/index.js";
|
|
25
|
+
export type { VDBBoxPyramidGpu, VDBBoxPyramidGpuOptions, VDBBoxPyramidRecordOptions } from "./compute/index.js";
|
|
26
|
+
export type { VDBBoxPyramidLayout, VDBPyramidAtlasLevel } from "../tools/frame/pyramid-layout.js";
|
|
27
|
+
export type { VDBAtlasFilter, VDBAtlasFormat, VDBAtlas, VDBAtlasReadback, VDBDecodeToAtlasOptions, VDBGridStats, VDBGridStatsOptions, VDBReadback, VDBValueTransform, VDBValueTransformPreset, } from "./compute/index.js";
|
|
28
|
+
export { vdbDenseSource } from "./source/dense.js";
|
|
29
|
+
export type { VDBDenseSource, VDBDenseSourceOptions } from "./source/dense.js";
|
|
30
|
+
export type { VDBVolumeChannels, VDBVolumeSource, VDBVolumeSourceInfo, VDBVolumeSourceWgslOptions } from "./source/types.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference types="@webgpu/types" preserve="true" />
|
|
2
|
+
/**
|
|
3
|
+
* @pmndrs/vdb (core) - the engine-free WebGPU core: a pool of NanoVDB grids in one storage buffer,
|
|
4
|
+
* the generated `vdb*` WGSL module that reads it, and compute tools that run on it.
|
|
5
|
+
*
|
|
6
|
+
* Everything usable without a GPU (the `.nvdb` loader, the CPU oracle, the `.vdb` tooling) lives in
|
|
7
|
+
* `@pmndrs/vdb/tools`. The core never imports `three` (test/boundaries.test.ts).
|
|
8
|
+
*
|
|
9
|
+
* This barrel is the public API (D32). The pool's binary layout helpers and other test oracles live in
|
|
10
|
+
* `./internal.ts`, imported by path by tests and harnesses; it is not a package export.
|
|
11
|
+
*/
|
|
12
|
+
export { VDBError } from "./errors.js";
|
|
13
|
+
export { VDBGridPool } from "./pool/pool.js";
|
|
14
|
+
/** The pool's GPU layout version, for `vdbCheckModule({ layoutVersion })`. */
|
|
15
|
+
export { VDB_GPU_LAYOUT_VERSION } from "./pool/layout.js";
|
|
16
|
+
// K1.4a: WGSL module generator (docs/dev/design/K1-core.md §3).
|
|
17
|
+
export { vdbCheckModule, vdbModuleEntries, vdbModuleWgsl } from "./wgsl/generate.js";
|
|
18
|
+
export { VDB_ALL_SCALAR_TYPES, VDB_GRID_TYPE_IDS, VDB_GRID_TYPE_NAMES } from "./types.js";
|
|
19
|
+
// K2.3: compute tools on the pool. The GPU tools carry the `Gpu` suffix: `@pmndrs/vdb/three` wraps them
|
|
20
|
+
// as `vdbGridStats` / `vdbDecodeToAtlas` (renderer in, promise out) and `@pmndrs/vdb/tools` has the
|
|
21
|
+
// `*Cpu` versions (D32).
|
|
22
|
+
export { vdbApplyValueTransform, vdbDecodeToAtlasGpu, vdbGridStatsGpu, VDB_VALUE_TRANSFORM_PRESETS } from "./compute/index.js";
|
|
23
|
+
// K3.2a: the sparse source's coarse pyramid built on the GPU.
|
|
24
|
+
export { vdbCreateBoxPyramid } from "./compute/index.js";
|
|
25
|
+
// K3.0: the volume-source seam (R1 §4.2) and its dense `.wvdb` source.
|
|
26
|
+
export { vdbDenseSource } from "./source/dense.js";
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAQ7C,8EAA8E;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,gEAAgE;AAChE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAWrF,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE1F,wGAAwG;AACxG,oGAAoG;AACpG,yBAAyB;AACzB,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAC/H,8DAA8D;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAezD,uEAAuE;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["/// <reference types=\"@webgpu/types\" preserve=\"true\" />\n/**\n * @pmndrs/vdb (core) - the engine-free WebGPU core: a pool of NanoVDB grids in one storage buffer,\n * the generated `vdb*` WGSL module that reads it, and compute tools that run on it.\n *\n * Everything usable without a GPU (the `.nvdb` loader, the CPU oracle, the `.vdb` tooling) lives in\n * `@pmndrs/vdb/tools`. The core never imports `three` (test/boundaries.test.ts).\n *\n * This barrel is the public API (D32). The pool's binary layout helpers and other test oracles live in\n * `./internal.ts`, imported by path by tests and harnesses; it is not a package export.\n */\n\nexport { VDBError } from \"./errors.js\";\nexport type { VDBErrorCode } from \"./errors.js\";\n\nexport { VDBGridPool } from \"./pool/pool.js\";\nexport type {\n VDBAddOptions,\n VDBBrickMajorant,\n VDBGridInfo,\n VDBGridPoolOptions,\n VDBTransformInput,\n} from \"./pool/pool.js\";\n/** The pool's GPU layout version, for `vdbCheckModule({ layoutVersion })`. */\nexport { VDB_GPU_LAYOUT_VERSION } from \"./pool/layout.js\";\nexport type { VDBVec3 } from \"./pool/layout.js\";\n// K1.4a: WGSL module generator (docs/dev/design/K1-core.md §3).\nexport { vdbCheckModule, vdbModuleEntries, vdbModuleWgsl } from \"./wgsl/generate.js\";\nexport type {\n VDBBufferModuleOptions,\n VDBModuleCommonOptions,\n VDBModuleHelper,\n VDBModuleOptions,\n VDBModulePoolLike,\n VDBModuleProfile,\n VDBModuleTypeCheck,\n VDBSlotModuleOptions,\n} from \"./wgsl/types.js\";\nexport { VDB_ALL_SCALAR_TYPES, VDB_GRID_TYPE_IDS, VDB_GRID_TYPE_NAMES } from \"./types.js\";\nexport type { VDBGridTypeName, VDBSlot } from \"./types.js\";\n// K2.3: compute tools on the pool. The GPU tools carry the `Gpu` suffix: `@pmndrs/vdb/three` wraps them\n// as `vdbGridStats` / `vdbDecodeToAtlas` (renderer in, promise out) and `@pmndrs/vdb/tools` has the\n// `*Cpu` versions (D32).\nexport { vdbApplyValueTransform, vdbDecodeToAtlasGpu, vdbGridStatsGpu, VDB_VALUE_TRANSFORM_PRESETS } from \"./compute/index.js\";\n// K3.2a: the sparse source's coarse pyramid built on the GPU.\nexport { vdbCreateBoxPyramid } from \"./compute/index.js\";\nexport type { VDBBoxPyramidGpu, VDBBoxPyramidGpuOptions, VDBBoxPyramidRecordOptions } from \"./compute/index.js\";\nexport type { VDBBoxPyramidLayout, VDBPyramidAtlasLevel } from \"../tools/frame/pyramid-layout.js\";\nexport type {\n VDBAtlasFilter,\n VDBAtlasFormat,\n VDBAtlas,\n VDBAtlasReadback,\n VDBDecodeToAtlasOptions,\n VDBGridStats,\n VDBGridStatsOptions,\n VDBReadback,\n VDBValueTransform,\n VDBValueTransformPreset,\n} from \"./compute/index.js\";\n// K3.0: the volume-source seam (R1 §4.2) and its dense `.wvdb` source.\nexport { vdbDenseSource } from \"./source/dense.js\";\nexport type { VDBDenseSource, VDBDenseSourceOptions } from \"./source/dense.js\";\nexport type { VDBVolumeChannels, VDBVolumeSource, VDBVolumeSourceInfo, VDBVolumeSourceWgslOptions } from \"./source/types.js\";\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @pmndrs/vdb core internals (D32): NOT a package export.
|
|
3
|
+
*
|
|
4
|
+
* Everything public (`./index.ts`) plus what tests, harnesses and scripts need that a user doesn't:
|
|
5
|
+
* the pool's binary layout (constants, header/record codecs, the layout WGSL), the module banner, the
|
|
6
|
+
* pyramid kernel's WGSL and the vendored module's URL. Import it by path (`src/core/internal.ts`, or
|
|
7
|
+
* `dist/core/internal.js` from a script after `pnpm build`); its names can change without notice.
|
|
8
|
+
*/
|
|
9
|
+
export * from "./index.js";
|
|
10
|
+
/** Resolvable URL of the vendored WGSL module (`@pmndrs/vdb/pnanovdb.wgsl`), for Node tests. */
|
|
11
|
+
export declare const pnanovdbWgslUrl: URL;
|
|
12
|
+
export { VDB_HEADER_WORD, VDB_POOL_ALIGN, VDB_POOL_HEADER_BYTES, VDB_POOL_MAGIC, VDB_POOL_RECORD_BYTES, VDB_POOL_RECORD_WORDS, VDB_POOL_TABLE_OFFSET, VDB_RECORD_FLAG, VDB_RECORD_WORD, decodeHeader, decodeRecord, encodeRecord, vdbPoolLayoutWgsl, } from "./pool/layout.js";
|
|
13
|
+
export type { VDBGridRecord, VDBPoolHeader } from "./pool/layout.js";
|
|
14
|
+
export { VDB_MODULE_BANNER } from "./wgsl/generate.js";
|
|
15
|
+
export { boxPyramidWgsl } from "./compute/index.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @pmndrs/vdb core internals (D32): NOT a package export.
|
|
3
|
+
*
|
|
4
|
+
* Everything public (`./index.ts`) plus what tests, harnesses and scripts need that a user doesn't:
|
|
5
|
+
* the pool's binary layout (constants, header/record codecs, the layout WGSL), the module banner, the
|
|
6
|
+
* pyramid kernel's WGSL and the vendored module's URL. Import it by path (`src/core/internal.ts`, or
|
|
7
|
+
* `dist/core/internal.js` from a script after `pnpm build`); its names can change without notice.
|
|
8
|
+
*/
|
|
9
|
+
export * from "./index.js";
|
|
10
|
+
/** Resolvable URL of the vendored WGSL module (`@pmndrs/vdb/pnanovdb.wgsl`), for Node tests. */
|
|
11
|
+
export const pnanovdbWgslUrl = new URL("../../vendor/pnanovdb.wgsl", import.meta.url);
|
|
12
|
+
export { VDB_HEADER_WORD, VDB_POOL_ALIGN, VDB_POOL_HEADER_BYTES, VDB_POOL_MAGIC, VDB_POOL_RECORD_BYTES, VDB_POOL_RECORD_WORDS, VDB_POOL_TABLE_OFFSET, VDB_RECORD_FLAG, VDB_RECORD_WORD, decodeHeader, decodeRecord, encodeRecord, vdbPoolLayoutWgsl, } from "./pool/layout.js";
|
|
13
|
+
export { VDB_MODULE_BANNER } from "./wgsl/generate.js";
|
|
14
|
+
export { boxPyramidWgsl } from "./compute/index.js";
|
|
15
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/core/internal.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,YAAY,CAAC;AAE3B,gGAAgG;AAChG,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,4BAA4B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEtF,OAAO,EACL,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["/**\n * @pmndrs/vdb core internals (D32): NOT a package export.\n *\n * Everything public (`./index.ts`) plus what tests, harnesses and scripts need that a user doesn't:\n * the pool's binary layout (constants, header/record codecs, the layout WGSL), the module banner, the\n * pyramid kernel's WGSL and the vendored module's URL. Import it by path (`src/core/internal.ts`, or\n * `dist/core/internal.js` from a script after `pnpm build`); its names can change without notice.\n */\n\nexport * from \"./index.js\";\n\n/** Resolvable URL of the vendored WGSL module (`@pmndrs/vdb/pnanovdb.wgsl`), for Node tests. */\nexport const pnanovdbWgslUrl = new URL(\"../../vendor/pnanovdb.wgsl\", import.meta.url);\n\nexport {\n VDB_HEADER_WORD,\n VDB_POOL_ALIGN,\n VDB_POOL_HEADER_BYTES,\n VDB_POOL_MAGIC,\n VDB_POOL_RECORD_BYTES,\n VDB_POOL_RECORD_WORDS,\n VDB_POOL_TABLE_OFFSET,\n VDB_RECORD_FLAG,\n VDB_RECORD_WORD,\n decodeHeader,\n decodeRecord,\n encodeRecord,\n vdbPoolLayoutWgsl,\n} from \"./pool/layout.js\";\nexport type { VDBGridRecord, VDBPoolHeader } from \"./pool/layout.js\";\nexport { VDB_MODULE_BANNER } from \"./wgsl/generate.js\";\nexport { boxPyramidWgsl } from \"./compute/index.js\";\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* f64 affine composition for grid records (docs/dev/design/K1-core.md §1.6).
|
|
3
|
+
* Affines here are 3x4 row-major: row r is `[m_r0, m_r1, m_r2, t_r]`, so
|
|
4
|
+
* `out_r = m_r0 x + m_r1 y + m_r2 z + t_r`. The record stores them rounded to f32.
|
|
5
|
+
* Negated translations are written `0 - x` so a zero stays +0 (stable record bits).
|
|
6
|
+
*/
|
|
7
|
+
import type { VDBImageHeader } from "./image-header.js";
|
|
8
|
+
import type { VDBVec3 } from "./layout.js";
|
|
9
|
+
/** A 3x4 row-major affine in f64. */
|
|
10
|
+
export type Affine3x4 = Float64Array;
|
|
11
|
+
/** World <-> index affines of one grid. */
|
|
12
|
+
export interface GridAffines {
|
|
13
|
+
worldToIndex: Affine3x4;
|
|
14
|
+
indexToWorld: Affine3x4;
|
|
15
|
+
}
|
|
16
|
+
/** `a ∘ b` (apply b, then a). */
|
|
17
|
+
export declare function composeAffine(a: Affine3x4, b: Affine3x4): Affine3x4;
|
|
18
|
+
/** Applies `m` to the point `p`. */
|
|
19
|
+
export declare function applyAffine(m: Affine3x4, p: ArrayLike<number>): VDBVec3;
|
|
20
|
+
/** The file's own map: index -> (object) world and its inverse, from `matD`/`invMatD`/`vecD`. */
|
|
21
|
+
export declare function fileAffines(header: VDBImageHeader): GridAffines;
|
|
22
|
+
/**
|
|
23
|
+
* Validates a 4x4 column-major `objectToWorld` (WebGPU / three convention) and
|
|
24
|
+
* returns it with its inverse as 3x4 affines. The bottom row must be `0 0 0 1`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function objectToWorldAffines(m: ArrayLike<number>): {
|
|
27
|
+
forward: Affine3x4;
|
|
28
|
+
inverse: Affine3x4;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The record's affines in f64: the file map, optionally followed by an instance
|
|
32
|
+
* `objectToWorld`. `worldToIndex = map⁻¹ ∘ objectToWorld⁻¹`, `indexToWorld = objectToWorld ∘ map`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function composeGridAffines(header: VDBImageHeader, objectToWorld: ArrayLike<number> | null): GridAffines;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* f64 affine composition for grid records (docs/dev/design/K1-core.md §1.6).
|
|
3
|
+
* Affines here are 3x4 row-major: row r is `[m_r0, m_r1, m_r2, t_r]`, so
|
|
4
|
+
* `out_r = m_r0 x + m_r1 y + m_r2 z + t_r`. The record stores them rounded to f32.
|
|
5
|
+
* Negated translations are written `0 - x` so a zero stays +0 (stable record bits).
|
|
6
|
+
*/
|
|
7
|
+
import { VDBError } from "../errors.js";
|
|
8
|
+
function invert3x3(m, what) {
|
|
9
|
+
const [a, b, c, d, e, f, g, h, i] = [m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8]];
|
|
10
|
+
const A = e * i - f * h;
|
|
11
|
+
const B = -(d * i - f * g);
|
|
12
|
+
const C = d * h - e * g;
|
|
13
|
+
const det = a * A + b * B + c * C;
|
|
14
|
+
if (!Number.isFinite(det) || det === 0) {
|
|
15
|
+
throw new VDBError("VDB_BAD_OPTION", `${what} is singular (determinant ${det}); pass an invertible matrix.`);
|
|
16
|
+
}
|
|
17
|
+
const s = 1 / det;
|
|
18
|
+
return new Float64Array([
|
|
19
|
+
A * s, -(b * i - c * h) * s, (b * f - c * e) * s,
|
|
20
|
+
B * s, (a * i - c * g) * s, -(a * f - c * d) * s,
|
|
21
|
+
C * s, -(a * h - b * g) * s, (a * e - b * d) * s,
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
24
|
+
/** Builds a 3x4 affine from a 3x3 row-major linear part and a translation. */
|
|
25
|
+
function affine(lin, t) {
|
|
26
|
+
const out = new Float64Array(12);
|
|
27
|
+
for (let r = 0; r < 3; r++) {
|
|
28
|
+
out[r * 4 + 0] = lin[r * 3 + 0];
|
|
29
|
+
out[r * 4 + 1] = lin[r * 3 + 1];
|
|
30
|
+
out[r * 4 + 2] = lin[r * 3 + 2];
|
|
31
|
+
out[r * 4 + 3] = t[r];
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
/** `a ∘ b` (apply b, then a). */
|
|
36
|
+
export function composeAffine(a, b) {
|
|
37
|
+
const out = new Float64Array(12);
|
|
38
|
+
for (let r = 0; r < 3; r++) {
|
|
39
|
+
for (let c = 0; c < 4; c++) {
|
|
40
|
+
let v = a[r * 4 + 0] * b[0 * 4 + c] + a[r * 4 + 1] * b[1 * 4 + c] + a[r * 4 + 2] * b[2 * 4 + c];
|
|
41
|
+
if (c === 3)
|
|
42
|
+
v += a[r * 4 + 3];
|
|
43
|
+
out[r * 4 + c] = v;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/** Applies `m` to the point `p`. */
|
|
49
|
+
export function applyAffine(m, p) {
|
|
50
|
+
const out = [0, 0, 0];
|
|
51
|
+
for (let r = 0; r < 3; r++) {
|
|
52
|
+
out[r] = m[r * 4] * p[0] + m[r * 4 + 1] * p[1] + m[r * 4 + 2] * p[2] + m[r * 4 + 3];
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
/** The file's own map: index -> (object) world and its inverse, from `matD`/`invMatD`/`vecD`. */
|
|
57
|
+
export function fileAffines(header) {
|
|
58
|
+
const { matD, invMatD, vecD } = header;
|
|
59
|
+
const t = [0, 1, 2].map((r) => 0 - (invMatD[r * 3] * vecD[0] + invMatD[r * 3 + 1] * vecD[1] + invMatD[r * 3 + 2] * vecD[2]));
|
|
60
|
+
return { indexToWorld: affine(matD, vecD), worldToIndex: affine(invMatD, t) };
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Validates a 4x4 column-major `objectToWorld` (WebGPU / three convention) and
|
|
64
|
+
* returns it with its inverse as 3x4 affines. The bottom row must be `0 0 0 1`.
|
|
65
|
+
*/
|
|
66
|
+
export function objectToWorldAffines(m) {
|
|
67
|
+
if (m.length !== 16) {
|
|
68
|
+
throw new VDBError("VDB_BAD_OPTION", `objectToWorld must have 16 entries (4x4 column-major), got ${m.length}.`);
|
|
69
|
+
}
|
|
70
|
+
for (let k = 0; k < 16; k++) {
|
|
71
|
+
if (!Number.isFinite(m[k])) {
|
|
72
|
+
throw new VDBError("VDB_BAD_OPTION", `objectToWorld[${k}] is ${m[k]}; every entry must be finite.`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (m[3] !== 0 || m[7] !== 0 || m[11] !== 0 || m[15] !== 1) {
|
|
76
|
+
throw new VDBError("VDB_BAD_OPTION", `objectToWorld must be affine (bottom row 0 0 0 1, i.e. entries 3, 7, 11, 15); got ${m[3]} ${m[7]} ${m[11]} ${m[15]}. ` +
|
|
77
|
+
`Pass a column-major matrix such as three's Matrix4.elements.`);
|
|
78
|
+
}
|
|
79
|
+
// Column-major: element (row r, column c) is m[c * 4 + r].
|
|
80
|
+
const lin = [m[0], m[4], m[8], m[1], m[5], m[9], m[2], m[6], m[10]];
|
|
81
|
+
const t = [m[12], m[13], m[14]];
|
|
82
|
+
const inv = invert3x3(lin, "objectToWorld");
|
|
83
|
+
const invT = [0, 1, 2].map((r) => 0 - (inv[r * 3] * t[0] + inv[r * 3 + 1] * t[1] + inv[r * 3 + 2] * t[2]));
|
|
84
|
+
return { forward: affine(lin, t), inverse: affine(inv, invT) };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The record's affines in f64: the file map, optionally followed by an instance
|
|
88
|
+
* `objectToWorld`. `worldToIndex = map⁻¹ ∘ objectToWorld⁻¹`, `indexToWorld = objectToWorld ∘ map`.
|
|
89
|
+
*/
|
|
90
|
+
export function composeGridAffines(header, objectToWorld) {
|
|
91
|
+
const file = fileAffines(header);
|
|
92
|
+
if (objectToWorld === null)
|
|
93
|
+
return file;
|
|
94
|
+
const o = objectToWorldAffines(objectToWorld);
|
|
95
|
+
return {
|
|
96
|
+
indexToWorld: composeAffine(o.forward, file.indexToWorld),
|
|
97
|
+
worldToIndex: composeAffine(file.worldToIndex, o.inverse),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=affine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"affine.js","sourceRoot":"","sources":["../../../src/core/pool/affine.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAaxC,SAAS,SAAS,CAAC,CAAoB,EAAE,IAAY;IACnD,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,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,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC;IACpG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,MAAM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CAAE,EAAE,CAAC,CAAC,EAAE,CAAE,EAAE,CAAC,CAAC,EAAE,CAAE,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC;IACjH,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC;AACjE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAsB,EAAE,aAAuC;IAChG,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,IAAI,aAAa,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACxC,MAAM,CAAC,GAAG,oBAAoB,CAAC,aAAa,CAAC,CAAC;IAC9C,OAAO;QACL,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC;QACzD,YAAY,EAAE,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC;KAC1D,CAAC;AACJ,CAAC","sourcesContent":["/**\n * f64 affine composition for grid records (docs/dev/design/K1-core.md §1.6).\n * Affines here are 3x4 row-major: row r is `[m_r0, m_r1, m_r2, t_r]`, so\n * `out_r = m_r0 x + m_r1 y + m_r2 z + t_r`. The record stores them rounded to f32.\n * Negated translations are written `0 - x` so a zero stays +0 (stable record bits).\n */\n\nimport { VDBError } from \"../errors.js\";\nimport type { VDBImageHeader } from \"./image-header.js\";\nimport type { VDBVec3 } from \"./layout.js\";\n\n/** A 3x4 row-major affine in f64. */\nexport type Affine3x4 = Float64Array;\n\n/** World <-> index affines of one grid. */\nexport interface GridAffines {\n worldToIndex: Affine3x4;\n indexToWorld: Affine3x4;\n}\n\nfunction invert3x3(m: ArrayLike<number>, what: string): Float64Array {\n const [a, b, c, d, e, f, g, h, i] = [m[0]!, m[1]!, m[2]!, m[3]!, m[4]!, m[5]!, m[6]!, m[7]!, m[8]!];\n const A = e * i - f * h;\n const B = -(d * i - f * g);\n const C = d * h - e * g;\n const det = a * A + b * B + c * C;\n if (!Number.isFinite(det) || det === 0) {\n throw new VDBError(\"VDB_BAD_OPTION\", `${what} is singular (determinant ${det}); pass an invertible matrix.`);\n }\n const s = 1 / det;\n return new Float64Array([\n A * s, -(b * i - c * h) * s, (b * f - c * e) * s,\n B * s, (a * i - c * g) * s, -(a * f - c * d) * s,\n C * s, -(a * h - b * g) * s, (a * e - b * d) * s,\n ]);\n}\n\n/** Builds a 3x4 affine from a 3x3 row-major linear part and a translation. */\nfunction affine(lin: ArrayLike<number>, t: ArrayLike<number>): Affine3x4 {\n const out = new Float64Array(12);\n for (let r = 0; r < 3; r++) {\n out[r * 4 + 0] = lin[r * 3 + 0]!;\n out[r * 4 + 1] = lin[r * 3 + 1]!;\n out[r * 4 + 2] = lin[r * 3 + 2]!;\n out[r * 4 + 3] = t[r]!;\n }\n return out;\n}\n\n/** `a ∘ b` (apply b, then a). */\nexport function composeAffine(a: Affine3x4, b: Affine3x4): Affine3x4 {\n const out = new Float64Array(12);\n for (let r = 0; r < 3; r++) {\n for (let c = 0; c < 4; c++) {\n let v = a[r * 4 + 0]! * b[0 * 4 + c]! + a[r * 4 + 1]! * b[1 * 4 + c]! + a[r * 4 + 2]! * b[2 * 4 + c]!;\n if (c === 3) v += a[r * 4 + 3]!;\n out[r * 4 + c] = v;\n }\n }\n return out;\n}\n\n/** Applies `m` to the point `p`. */\nexport function applyAffine(m: Affine3x4, p: ArrayLike<number>): VDBVec3 {\n const out: VDBVec3 = [0, 0, 0];\n for (let r = 0; r < 3; r++) {\n out[r] = m[r * 4]! * p[0]! + m[r * 4 + 1]! * p[1]! + m[r * 4 + 2]! * p[2]! + m[r * 4 + 3]!;\n }\n return out;\n}\n\n/** The file's own map: index -> (object) world and its inverse, from `matD`/`invMatD`/`vecD`. */\nexport function fileAffines(header: VDBImageHeader): GridAffines {\n const { matD, invMatD, vecD } = header;\n const t = [0, 1, 2].map((r) => 0 - (invMatD[r * 3]! * vecD[0]! + invMatD[r * 3 + 1]! * vecD[1]! + invMatD[r * 3 + 2]! * vecD[2]!));\n return { indexToWorld: affine(matD, vecD), worldToIndex: affine(invMatD, t) };\n}\n\n/**\n * Validates a 4x4 column-major `objectToWorld` (WebGPU / three convention) and\n * returns it with its inverse as 3x4 affines. The bottom row must be `0 0 0 1`.\n */\nexport function objectToWorldAffines(m: ArrayLike<number>): { forward: Affine3x4; inverse: Affine3x4 } {\n if (m.length !== 16) {\n throw new VDBError(\"VDB_BAD_OPTION\", `objectToWorld must have 16 entries (4x4 column-major), got ${m.length}.`);\n }\n for (let k = 0; k < 16; k++) {\n if (!Number.isFinite(m[k])) {\n throw new VDBError(\"VDB_BAD_OPTION\", `objectToWorld[${k}] is ${m[k]}; every entry must be finite.`);\n }\n }\n if (m[3] !== 0 || m[7] !== 0 || m[11] !== 0 || m[15] !== 1) {\n throw new VDBError(\n \"VDB_BAD_OPTION\",\n `objectToWorld must be affine (bottom row 0 0 0 1, i.e. entries 3, 7, 11, 15); got ${m[3]} ${m[7]} ${m[11]} ${m[15]}. ` +\n `Pass a column-major matrix such as three's Matrix4.elements.`,\n );\n }\n // Column-major: element (row r, column c) is m[c * 4 + r].\n const lin = [m[0]!, m[4]!, m[8]!, m[1]!, m[5]!, m[9]!, m[2]!, m[6]!, m[10]!];\n const t = [m[12]!, m[13]!, m[14]!];\n const inv = invert3x3(lin, \"objectToWorld\");\n const invT = [0, 1, 2].map((r) => 0 - (inv[r * 3]! * t[0]! + inv[r * 3 + 1]! * t[1]! + inv[r * 3 + 2]! * t[2]!));\n return { forward: affine(lin, t), inverse: affine(inv, invT) };\n}\n\n/**\n * The record's affines in f64: the file map, optionally followed by an instance\n * `objectToWorld`. `worldToIndex = map⁻¹ ∘ objectToWorld⁻¹`, `indexToWorld = objectToWorld ∘ map`.\n */\nexport function composeGridAffines(header: VDBImageHeader, objectToWorld: ArrayLike<number> | null): GridAffines {\n const file = fileAffines(header);\n if (objectToWorld === null) return file;\n const o = objectToWorldAffines(objectToWorld);\n return {\n indexToWorld: composeAffine(o.forward, file.indexToWorld),\n worldToIndex: composeAffine(file.worldToIndex, o.inverse),\n };\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First-fit range allocator in 32-byte units over `[start, end)` of the pool
|
|
3
|
+
* (docs/dev/design/K1-core.md §1.3–1.4). It only does bookkeeping; moving data is the
|
|
4
|
+
* pool's job (growth and compaction in `update`).
|
|
5
|
+
*/
|
|
6
|
+
/** One allocated range. */
|
|
7
|
+
export interface AllocatedRange {
|
|
8
|
+
offset: number;
|
|
9
|
+
size: number;
|
|
10
|
+
}
|
|
11
|
+
/** First-fit allocator. Sizes are rounded up to 32 bytes; offsets are 32-byte aligned. */
|
|
12
|
+
export declare class RangeAllocator {
|
|
13
|
+
#private;
|
|
14
|
+
/** @param start first usable byte (32-aligned) @param end one past the last usable byte */
|
|
15
|
+
constructor(start: number, end: number);
|
|
16
|
+
get start(): number;
|
|
17
|
+
get end(): number;
|
|
18
|
+
/** Bytes currently allocated (rounded sizes). */
|
|
19
|
+
get allocatedBytes(): number;
|
|
20
|
+
/** End of the highest allocated range, or `start` when empty. */
|
|
21
|
+
get highWater(): number;
|
|
22
|
+
/** Allocated ranges in offset order (copies). */
|
|
23
|
+
ranges(): AllocatedRange[];
|
|
24
|
+
/** Allocates `bytes` (rounded up to 32) at the lowest offset that fits; `null` when no gap does. */
|
|
25
|
+
alloc(bytes: number): number | null;
|
|
26
|
+
/** Frees the range starting at `offset`. Throws if no range starts there (a pool bug). */
|
|
27
|
+
free(offset: number): void;
|
|
28
|
+
/** Re-inserts a range that was just freed (undo of `free`). Throws if it overlaps an allocation (a pool bug). */
|
|
29
|
+
restore(range: AllocatedRange): void;
|
|
30
|
+
/** Size of the range starting at `offset`, or `undefined`. */
|
|
31
|
+
sizeAt(offset: number): number | undefined;
|
|
32
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* First-fit range allocator in 32-byte units over `[start, end)` of the pool
|
|
3
|
+
* (docs/dev/design/K1-core.md §1.3–1.4). It only does bookkeeping; moving data is the
|
|
4
|
+
* pool's job (growth and compaction in `update`).
|
|
5
|
+
*/
|
|
6
|
+
import { VDB_POOL_ALIGN, align32 } from "./layout.js";
|
|
7
|
+
/** First-fit allocator. Sizes are rounded up to 32 bytes; offsets are 32-byte aligned. */
|
|
8
|
+
export class RangeAllocator {
|
|
9
|
+
/** Allocated ranges sorted by offset. */
|
|
10
|
+
#ranges = [];
|
|
11
|
+
#start;
|
|
12
|
+
#end;
|
|
13
|
+
/** @param start first usable byte (32-aligned) @param end one past the last usable byte */
|
|
14
|
+
constructor(start, end) {
|
|
15
|
+
if (start % VDB_POOL_ALIGN !== 0)
|
|
16
|
+
throw new Error(`RangeAllocator: start ${start} is not 32-byte aligned.`);
|
|
17
|
+
this.#start = start;
|
|
18
|
+
this.#end = end;
|
|
19
|
+
}
|
|
20
|
+
get start() {
|
|
21
|
+
return this.#start;
|
|
22
|
+
}
|
|
23
|
+
get end() {
|
|
24
|
+
return this.#end;
|
|
25
|
+
}
|
|
26
|
+
/** Bytes currently allocated (rounded sizes). */
|
|
27
|
+
get allocatedBytes() {
|
|
28
|
+
let n = 0;
|
|
29
|
+
for (const r of this.#ranges)
|
|
30
|
+
n += r.size;
|
|
31
|
+
return n;
|
|
32
|
+
}
|
|
33
|
+
/** End of the highest allocated range, or `start` when empty. */
|
|
34
|
+
get highWater() {
|
|
35
|
+
const last = this.#ranges[this.#ranges.length - 1];
|
|
36
|
+
return last ? last.offset + last.size : this.#start;
|
|
37
|
+
}
|
|
38
|
+
/** Allocated ranges in offset order (copies). */
|
|
39
|
+
ranges() {
|
|
40
|
+
return this.#ranges.map((r) => ({ ...r }));
|
|
41
|
+
}
|
|
42
|
+
/** Allocates `bytes` (rounded up to 32) at the lowest offset that fits; `null` when no gap does. */
|
|
43
|
+
alloc(bytes) {
|
|
44
|
+
const size = align32(Math.max(bytes, 1));
|
|
45
|
+
let cursor = this.#start;
|
|
46
|
+
for (let i = 0; i <= this.#ranges.length; i++) {
|
|
47
|
+
const next = this.#ranges[i];
|
|
48
|
+
const gapEnd = next ? next.offset : this.#end;
|
|
49
|
+
if (gapEnd - cursor >= size) {
|
|
50
|
+
this.#ranges.splice(i, 0, { offset: cursor, size });
|
|
51
|
+
return cursor;
|
|
52
|
+
}
|
|
53
|
+
if (next)
|
|
54
|
+
cursor = next.offset + next.size;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
/** Frees the range starting at `offset`. Throws if no range starts there (a pool bug). */
|
|
59
|
+
free(offset) {
|
|
60
|
+
const i = this.#ranges.findIndex((r) => r.offset === offset);
|
|
61
|
+
if (i < 0)
|
|
62
|
+
throw new Error(`RangeAllocator: no range at offset ${offset}.`);
|
|
63
|
+
this.#ranges.splice(i, 1);
|
|
64
|
+
}
|
|
65
|
+
/** Re-inserts a range that was just freed (undo of `free`). Throws if it overlaps an allocation (a pool bug). */
|
|
66
|
+
restore(range) {
|
|
67
|
+
const i = this.#ranges.findIndex((r) => r.offset > range.offset);
|
|
68
|
+
const at = i < 0 ? this.#ranges.length : i;
|
|
69
|
+
const prev = this.#ranges[at - 1];
|
|
70
|
+
const next = this.#ranges[at];
|
|
71
|
+
if ((prev && prev.offset + prev.size > range.offset) || (next && range.offset + range.size > next.offset)) {
|
|
72
|
+
throw new Error(`RangeAllocator: cannot restore [${range.offset}, +${range.size}); it overlaps an allocation.`);
|
|
73
|
+
}
|
|
74
|
+
this.#ranges.splice(at, 0, { ...range });
|
|
75
|
+
}
|
|
76
|
+
/** Size of the range starting at `offset`, or `undefined`. */
|
|
77
|
+
sizeAt(offset) {
|
|
78
|
+
return this.#ranges.find((r) => r.offset === offset)?.size;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=allocator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allocator.js","sourceRoot":"","sources":["../../../src/core/pool/allocator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAQtD,0FAA0F;AAC1F,MAAM,OAAO,cAAc;IACzB,yCAAyC;IACzC,OAAO,GAAqB,EAAE,CAAC;IAC/B,MAAM,CAAS;IACf,IAAI,CAAS;IAEb,2FAA2F;IAC3F,YAAY,KAAa,EAAE,GAAW;QACpC,IAAI,KAAK,GAAG,cAAc,KAAK,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,0BAA0B,CAAC,CAAC;QAC5G,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,iDAAiD;IACjD,IAAI,cAAc;QAChB,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO;YAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;Q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CAAC,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,8DAA8D;IAC9D,MAAM,CAAC,MAAc;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC;IAC7D,CAAC;CACF","sourcesContent":["/**\n * First-fit range allocator in 32-byte units over `[start, end)` of the pool\n * (docs/dev/design/K1-core.md §1.3–1.4). It only does bookkeeping; moving data is the\n * pool's job (growth and compaction in `update`).\n */\n\nimport { VDB_POOL_ALIGN, align32 } from \"./layout.js\";\n\n/** One allocated range. */\nexport interface AllocatedRange {\n offset: number;\n size: number;\n}\n\n/** First-fit allocator. Sizes are rounded up to 32 bytes; offsets are 32-byte aligned. */\nexport class RangeAllocator {\n /** Allocated ranges sorted by offset. */\n #ranges: AllocatedRange[] = [];\n #start: number;\n #end: number;\n\n /** @param start first usable byte (32-aligned) @param end one past the last usable byte */\n constructor(start: number, end: number) {\n if (start % VDB_POOL_ALIGN !== 0) throw new Error(`RangeAllocator: start ${start} is not 32-byte aligned.`);\n this.#start = start;\n this.#end = end;\n }\n\n get start(): number {\n return this.#start;\n }\n\n get end(): number {\n return this.#end;\n }\n\n /** Bytes currently allocated (rounded sizes). */\n get allocatedBytes(): number {\n let n = 0;\n for (const r of this.#ranges) n += r.size;\n return n;\n }\n\n /** End of the highest allocated range, or `start` when empty. */\n get highWater(): number {\n const last = this.#ranges[this.#ranges.length - 1];\n return last ? last.offset + last.size : this.#start;\n }\n\n /** Allocated ranges in offset order (copies). */\n ranges(): AllocatedRange[] {\n return this.#ranges.map((r) => ({ ...r }));\n }\n\n /** Allocates `bytes` (rounded up to 32) at the lowest offset that fits; `null` when no gap does. */\n alloc(bytes: number): number | null {\n const size = align32(Math.max(bytes, 1));\n let cursor = this.#start;\n for (let i = 0; i <= this.#ranges.length; i++) {\n const next = this.#ranges[i];\n const gapEnd = next ? next.offset : this.#end;\n if (gapEnd - cursor >= size) {\n this.#ranges.splice(i, 0, { offset: cursor, size });\n return cursor;\n }\n if (next) cursor = next.offset + next.size;\n }\n return null;\n }\n\n /** Frees the range starting at `offset`. Throws if no range starts there (a pool bug). */\n free(offset: number): void {\n const i = this.#ranges.findIndex((r) => r.offset === offset);\n if (i < 0) throw new Error(`RangeAllocator: no range at offset ${offset}.`);\n this.#ranges.splice(i, 1);\n }\n\n /** Re-inserts a range that was just freed (undo of `free`). Throws if it overlaps an allocation (a pool bug). */\n restore(range: AllocatedRange): void {\n const i = this.#ranges.findIndex((r) => r.offset > range.offset);\n const at = i < 0 ? this.#ranges.length : i;\n const prev = this.#ranges[at - 1];\n const next = this.#ranges[at];\n if ((prev && prev.offset + prev.size > range.offset) || (next && range.offset + range.size > next.offset)) {\n throw new Error(`RangeAllocator: cannot restore [${range.offset}, +${range.size}); it overlaps an allocation.`);\n }\n this.#ranges.splice(at, 0, { ...range });\n }\n\n /** Size of the range starting at `offset`, or `undefined`. */\n sizeAt(offset: number): number | undefined {\n return this.#ranges.find((r) => r.offset === offset)?.size;\n }\n}\n"]}
|
|
@@ -0,0 +1,82 @@
|
|
|
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.9.1, PNanoVDB.h).
|
|
7
|
+
*/
|
|
8
|
+
import { type VDBGridTypeName } from "../types.js";
|
|
9
|
+
import type { VDBVec3 } from "./layout.js";
|
|
10
|
+
/** Byte offsets inside a NanoVDB grid image used by the pool. */
|
|
11
|
+
export declare const NANOVDB_OFFSETS: {
|
|
12
|
+
/** `GridData` size; `TreeData` follows it. */
|
|
13
|
+
readonly gridSize: 672;
|
|
14
|
+
readonly gridMagic: 0;
|
|
15
|
+
readonly gridVersion: 16;
|
|
16
|
+
readonly gridFlags: 20;
|
|
17
|
+
/** u64 `mGridSize`. */
|
|
18
|
+
readonly gridByteSize: 32;
|
|
19
|
+
readonly gridName: 40;
|
|
20
|
+
readonly gridNameMax: 256;
|
|
21
|
+
readonly gridMap: 296;
|
|
22
|
+
readonly mapMatD: 88;
|
|
23
|
+
readonly mapInvMatD: 160;
|
|
24
|
+
readonly mapVecD: 232;
|
|
25
|
+
readonly gridWorldBBox: 560;
|
|
26
|
+
readonly gridVoxelSize: 608;
|
|
27
|
+
readonly gridClass: 632;
|
|
28
|
+
readonly gridType: 636;
|
|
29
|
+
readonly treeSize: 64;
|
|
30
|
+
/** u64, relative to `TreeData`. */
|
|
31
|
+
readonly treeNodeOffsetRoot: 24;
|
|
32
|
+
readonly rootBBoxMin: 0;
|
|
33
|
+
readonly rootBBoxMax: 12;
|
|
34
|
+
/** `RootData` base size before the typed background/stats. */
|
|
35
|
+
readonly rootBaseSize: 28;
|
|
36
|
+
/** Typed root fields for Float/Fp4/Fp8/Fp16/FpN (all store f32 here). */
|
|
37
|
+
readonly rootBackground: 28;
|
|
38
|
+
readonly rootMin: 32;
|
|
39
|
+
readonly rootMax: 36;
|
|
40
|
+
/** Smallest `RootData` for the supported types (stride table `root_size`). */
|
|
41
|
+
readonly rootSize: 64;
|
|
42
|
+
};
|
|
43
|
+
/** `GridData.mFlags` bit for min/max statistics (NanoVDB `GridFlags::HasMinMax`). */
|
|
44
|
+
export declare const NANOVDB_FLAG_HAS_MIN_MAX: number;
|
|
45
|
+
/** NanoVDB ABI major this core reads. */
|
|
46
|
+
export declare const NANOVDB_ABI_MAJOR = 32;
|
|
47
|
+
/** Maps a NanoVDB `GridType` id to its pool type name, or `null` when the pool can't hold it. */
|
|
48
|
+
export declare function gridTypeName(id: number): VDBGridTypeName | null;
|
|
49
|
+
/** NanoVDB `GridClass` name for an id (`"Unknown(n)"` past the known range). */
|
|
50
|
+
export declare function gridClassName(id: number): string;
|
|
51
|
+
/** What the pool reads from a grid image's header. */
|
|
52
|
+
export interface VDBImageHeader {
|
|
53
|
+
gridType: VDBGridTypeName;
|
|
54
|
+
gridTypeId: number;
|
|
55
|
+
gridClass: number;
|
|
56
|
+
name: string;
|
|
57
|
+
/** `GridData.mFlags`. */
|
|
58
|
+
flags: number;
|
|
59
|
+
hasStats: boolean;
|
|
60
|
+
/** Bytes in the image (`mGridSize`, equal to the array's byte length). */
|
|
61
|
+
byteLength: number;
|
|
62
|
+
/** f64 3x3 row-major index -> world linear part. */
|
|
63
|
+
matD: Float64Array;
|
|
64
|
+
/** f64 3x3 row-major world -> index linear part. */
|
|
65
|
+
invMatD: Float64Array;
|
|
66
|
+
/** f64 translation: `world = matD * ijk + vecD`. */
|
|
67
|
+
vecD: Float64Array;
|
|
68
|
+
indexBBoxMin: VDBVec3;
|
|
69
|
+
indexBBoxMax: VDBVec3;
|
|
70
|
+
voxelSize: VDBVec3;
|
|
71
|
+
background: number;
|
|
72
|
+
/** Root min statistic (f32 as stored); meaningful only when `hasStats`. */
|
|
73
|
+
rootMin: number;
|
|
74
|
+
/** Root max statistic; meaningful only when `hasStats`. */
|
|
75
|
+
rootMax: number;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Parses and validates the header of a NanoVDB grid image (one grid, as
|
|
79
|
+
* `NvdbFile` from `@pmndrs/vdb/tools` returns it). Throws `VDB_BAD_IMAGE` or
|
|
80
|
+
* `VDB_UNSUPPORTED_GRID_TYPE` with the fix in the message.
|
|
81
|
+
*/
|
|
82
|
+
export declare function readImageHeader(image: Uint32Array, what?: string): VDBImageHeader;
|