@pmndrs/vdb 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +727 -0
- package/LICENSE +21 -0
- package/README.md +496 -2
- package/THIRD_PARTY_NOTICES.md +315 -0
- package/dist/core/compute/atlas.d.ts +102 -0
- package/dist/core/compute/atlas.js +103 -0
- package/dist/core/compute/atlas.js.map +1 -0
- package/dist/core/compute/index.d.ts +13 -0
- package/dist/core/compute/index.js +9 -0
- package/dist/core/compute/index.js.map +1 -0
- package/dist/core/compute/majorant-build.d.ts +45 -0
- package/dist/core/compute/majorant-build.js +193 -0
- package/dist/core/compute/majorant-build.js.map +1 -0
- package/dist/core/compute/multi-scale.d.ts +155 -0
- package/dist/core/compute/multi-scale.js +684 -0
- package/dist/core/compute/multi-scale.js.map +1 -0
- package/dist/core/compute/pyramid.d.ts +120 -0
- package/dist/core/compute/pyramid.js +468 -0
- package/dist/core/compute/pyramid.js.map +1 -0
- package/dist/core/compute/shared.d.ts +116 -0
- package/dist/core/compute/shared.js +211 -0
- package/dist/core/compute/shared.js.map +1 -0
- package/dist/core/compute/stats.d.ts +78 -0
- package/dist/core/compute/stats.js +193 -0
- package/dist/core/compute/stats.js.map +1 -0
- package/dist/core/compute/value-transform.d.ts +30 -0
- package/dist/core/compute/value-transform.js +64 -0
- package/dist/core/compute/value-transform.js.map +1 -0
- package/dist/core/errors.d.ts +21 -0
- package/dist/core/errors.js +17 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/frame/emission.d.ts +85 -0
- package/dist/core/frame/emission.js +422 -0
- package/dist/core/frame/emission.js.map +1 -0
- package/dist/core/frame/environment.d.ts +47 -0
- package/dist/core/frame/environment.js +178 -0
- package/dist/core/frame/environment.js.map +1 -0
- package/dist/core/frame/index.d.ts +39 -0
- package/dist/core/frame/index.js +27 -0
- package/dist/core/frame/index.js.map +1 -0
- package/dist/core/frame/kernels.d.ts +115 -0
- package/dist/core/frame/kernels.js +496 -0
- package/dist/core/frame/kernels.js.map +1 -0
- package/dist/core/frame/limits.d.ts +67 -0
- package/dist/core/frame/limits.js +109 -0
- package/dist/core/frame/limits.js.map +1 -0
- package/dist/core/frame/phase.d.ts +17 -0
- package/dist/core/frame/phase.js +53 -0
- package/dist/core/frame/phase.js.map +1 -0
- package/dist/core/frame/pipelines.d.ts +49 -0
- package/dist/core/frame/pipelines.js +147 -0
- package/dist/core/frame/pipelines.js.map +1 -0
- package/dist/core/frame/renderer.d.ts +122 -0
- package/dist/core/frame/renderer.js +1712 -0
- package/dist/core/frame/renderer.js.map +1 -0
- package/dist/core/frame/resources.d.ts +71 -0
- package/dist/core/frame/resources.js +100 -0
- package/dist/core/frame/resources.js.map +1 -0
- package/dist/core/frame/scattering.d.ts +97 -0
- package/dist/core/frame/scattering.js +332 -0
- package/dist/core/frame/scattering.js.map +1 -0
- package/dist/core/frame/settings.d.ts +243 -0
- package/dist/core/frame/settings.js +67 -0
- package/dist/core/frame/settings.js.map +1 -0
- package/dist/core/frame/shadows.d.ts +55 -0
- package/dist/core/frame/shadows.js +460 -0
- package/dist/core/frame/shadows.js.map +1 -0
- package/dist/core/frame/types.d.ts +415 -0
- package/dist/core/frame/types.js +49 -0
- package/dist/core/frame/types.js.map +1 -0
- package/dist/core/frame/uniforms.d.ts +105 -0
- package/dist/core/frame/uniforms.js +276 -0
- package/dist/core/frame/uniforms.js.map +1 -0
- package/dist/core/frame/wgsl/chunks.d.ts +4 -0
- package/dist/core/frame/wgsl/chunks.js +728 -0
- package/dist/core/frame/wgsl/chunks.js.map +1 -0
- package/dist/core/frame/wgsl/emission.d.ts +82 -0
- package/dist/core/frame/wgsl/emission.js +353 -0
- package/dist/core/frame/wgsl/emission.js.map +1 -0
- package/dist/core/frame/wgsl/environment.d.ts +42 -0
- package/dist/core/frame/wgsl/environment.js +711 -0
- package/dist/core/frame/wgsl/environment.js.map +1 -0
- package/dist/core/frame/wgsl/gather.d.ts +55 -0
- package/dist/core/frame/wgsl/gather.js +850 -0
- package/dist/core/frame/wgsl/gather.js.map +1 -0
- package/dist/core/frame/wgsl/integrate.d.ts +78 -0
- package/dist/core/frame/wgsl/integrate.js +213 -0
- package/dist/core/frame/wgsl/integrate.js.map +1 -0
- package/dist/core/frame/wgsl/lighting.d.ts +103 -0
- package/dist/core/frame/wgsl/lighting.js +1636 -0
- package/dist/core/frame/wgsl/lighting.js.map +1 -0
- package/dist/core/frame/wgsl/occluders.d.ts +20 -0
- package/dist/core/frame/wgsl/occluders.js +95 -0
- package/dist/core/frame/wgsl/occluders.js.map +1 -0
- package/dist/core/frame/wgsl/resolve.d.ts +19 -0
- package/dist/core/frame/wgsl/resolve.js +205 -0
- package/dist/core/frame/wgsl/resolve.js.map +1 -0
- package/dist/core/frame/wgsl/shadows.d.ts +35 -0
- package/dist/core/frame/wgsl/shadows.js +328 -0
- package/dist/core/frame/wgsl/shadows.js.map +1 -0
- package/dist/core/half.d.ts +11 -0
- package/dist/core/half.js +22 -0
- package/dist/core/half.js.map +1 -0
- package/dist/core/index.d.ts +52 -0
- package/dist/core/index.js +46 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/internal.d.ts +31 -0
- package/dist/core/internal.js +32 -0
- package/dist/core/internal.js.map +1 -0
- package/dist/core/pool/affine.d.ts +34 -0
- package/dist/core/pool/affine.js +100 -0
- package/dist/core/pool/affine.js.map +1 -0
- package/dist/core/pool/allocator.d.ts +32 -0
- package/dist/core/pool/allocator.js +81 -0
- package/dist/core/pool/allocator.js.map +1 -0
- package/dist/core/pool/image-header.d.ts +93 -0
- package/dist/core/pool/image-header.js +194 -0
- package/dist/core/pool/image-header.js.map +1 -0
- package/dist/core/pool/layout.d.ts +198 -0
- package/dist/core/pool/layout.js +316 -0
- package/dist/core/pool/layout.js.map +1 -0
- package/dist/core/pool/limits.d.ts +41 -0
- package/dist/core/pool/limits.js +80 -0
- package/dist/core/pool/limits.js.map +1 -0
- package/dist/core/pool/pool.d.ts +384 -0
- package/dist/core/pool/pool.js +1184 -0
- package/dist/core/pool/pool.js.map +1 -0
- package/dist/core/reference/index.d.ts +6 -0
- package/dist/core/reference/index.js +7 -0
- package/dist/core/reference/index.js.map +1 -0
- package/dist/core/reference/renderer.d.ts +105 -0
- package/dist/core/reference/renderer.js +474 -0
- package/dist/core/reference/renderer.js.map +1 -0
- package/dist/core/reference/wgsl.d.ts +65 -0
- package/dist/core/reference/wgsl.js +803 -0
- package/dist/core/reference/wgsl.js.map +1 -0
- package/dist/core/sequence.d.ts +347 -0
- package/dist/core/sequence.js +548 -0
- package/dist/core/sequence.js.map +1 -0
- package/dist/core/source/brick-cache.d.ts +165 -0
- package/dist/core/source/brick-cache.js +627 -0
- package/dist/core/source/brick-cache.js.map +1 -0
- package/dist/core/source/dense-fill.d.ts +53 -0
- package/dist/core/source/dense-fill.js +377 -0
- package/dist/core/source/dense-fill.js.map +1 -0
- package/dist/core/source/dense.d.ts +50 -0
- package/dist/core/source/dense.js +384 -0
- package/dist/core/source/dense.js.map +1 -0
- package/dist/core/source/sparse-wgsl.d.ts +92 -0
- package/dist/core/source/sparse-wgsl.js +481 -0
- package/dist/core/source/sparse-wgsl.js.map +1 -0
- package/dist/core/source/sparse.d.ts +192 -0
- package/dist/core/source/sparse.js +762 -0
- package/dist/core/source/sparse.js.map +1 -0
- package/dist/core/source/types.d.ts +120 -0
- package/dist/core/source/types.js +9 -0
- package/dist/core/source/types.js.map +1 -0
- package/dist/core/surface/index.d.ts +10 -0
- package/dist/core/surface/index.js +9 -0
- package/dist/core/surface/index.js.map +1 -0
- package/dist/core/surface/level-set-pass.d.ts +140 -0
- package/dist/core/surface/level-set-pass.js +291 -0
- package/dist/core/surface/level-set-pass.js.map +1 -0
- package/dist/core/surface/level-set-wgsl.d.ts +46 -0
- package/dist/core/surface/level-set-wgsl.js +99 -0
- package/dist/core/surface/level-set-wgsl.js.map +1 -0
- package/dist/core/surface/points.d.ts +109 -0
- package/dist/core/surface/points.js +226 -0
- package/dist/core/surface/points.js.map +1 -0
- package/dist/core/types.d.ts +37 -0
- package/dist/core/types.js +32 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/wgsl/api.d.ts +65 -0
- package/dist/core/wgsl/api.js +546 -0
- package/dist/core/wgsl/api.js.map +1 -0
- package/dist/core/wgsl/generate.d.ts +90 -0
- package/dist/core/wgsl/generate.js +678 -0
- package/dist/core/wgsl/generate.js.map +1 -0
- package/dist/core/wgsl/lean.d.ts +50 -0
- package/dist/core/wgsl/lean.js +327 -0
- package/dist/core/wgsl/lean.js.map +1 -0
- package/dist/core/wgsl/level-set.d.ts +58 -0
- package/dist/core/wgsl/level-set.js +200 -0
- package/dist/core/wgsl/level-set.js.map +1 -0
- package/dist/core/wgsl/majorant.d.ts +62 -0
- package/dist/core/wgsl/majorant.js +381 -0
- package/dist/core/wgsl/majorant.js.map +1 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.d.ts +14 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.js +333 -0
- package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -0
- package/dist/core/wgsl/reserved.d.ts +9 -0
- package/dist/core/wgsl/reserved.js +26 -0
- package/dist/core/wgsl/reserved.js.map +1 -0
- package/dist/core/wgsl/types.d.ts +198 -0
- package/dist/core/wgsl/types.js +2 -0
- package/dist/core/wgsl/types.js.map +1 -0
- package/dist/three/coarse-first.d.ts +207 -0
- package/dist/three/coarse-first.js +205 -0
- package/dist/three/coarse-first.js.map +1 -0
- package/dist/three/compute.d.ts +73 -0
- package/dist/three/compute.js +66 -0
- package/dist/three/compute.js.map +1 -0
- package/dist/three/device.d.ts +66 -0
- package/dist/three/device.js +62 -0
- package/dist/three/device.js.map +1 -0
- package/dist/three/frame/core-environment.d.ts +38 -0
- package/dist/three/frame/core-environment.js +154 -0
- package/dist/three/frame/core-environment.js.map +1 -0
- package/dist/three/frame/core-integrate-material.d.ts +34 -0
- package/dist/three/frame/core-integrate-material.js +162 -0
- package/dist/three/frame/core-integrate-material.js.map +1 -0
- package/dist/three/frame/core-occluders.d.ts +53 -0
- package/dist/three/frame/core-occluders.js +193 -0
- package/dist/three/frame/core-occluders.js.map +1 -0
- package/dist/three/frame/core-structs.d.ts +34 -0
- package/dist/three/frame/core-structs.js +61 -0
- package/dist/three/frame/core-structs.js.map +1 -0
- package/dist/three/frame/core-textures.d.ts +41 -0
- package/dist/three/frame/core-textures.js +114 -0
- package/dist/three/frame/core-textures.js.map +1 -0
- package/dist/three/frame/emission-light.d.ts +117 -0
- package/dist/three/frame/emission-light.js +276 -0
- package/dist/three/frame/emission-light.js.map +1 -0
- package/dist/three/frame/index.d.ts +19 -0
- package/dist/three/frame/index.js +15 -0
- package/dist/three/frame/index.js.map +1 -0
- package/dist/three/frame/medium.d.ts +33 -0
- package/dist/three/frame/medium.js +29 -0
- package/dist/three/frame/medium.js.map +1 -0
- package/dist/three/frame/renderer.d.ts +97 -0
- package/dist/three/frame/renderer.js +480 -0
- package/dist/three/frame/renderer.js.map +1 -0
- package/dist/three/frame/spectrum.d.ts +4 -0
- package/dist/three/frame/spectrum.js +15 -0
- package/dist/three/frame/spectrum.js.map +1 -0
- package/dist/three/frame/three-internals.d.ts +60 -0
- package/dist/three/frame/three-internals.js +152 -0
- package/dist/three/frame/three-internals.js.map +1 -0
- package/dist/three/frame/volume-shadows.d.ts +139 -0
- package/dist/three/frame/volume-shadows.js +403 -0
- package/dist/three/frame/volume-shadows.js.map +1 -0
- package/dist/three/frame/volume.d.ts +230 -0
- package/dist/three/frame/volume.js +268 -0
- package/dist/three/frame/volume.js.map +1 -0
- package/dist/three/grid-node.d.ts +229 -0
- package/dist/three/grid-node.js +545 -0
- package/dist/three/grid-node.js.map +1 -0
- package/dist/three/index.d.ts +52 -0
- package/dist/three/index.js +58 -0
- package/dist/three/index.js.map +1 -0
- package/dist/three/internal.d.ts +20 -0
- package/dist/three/internal.js +18 -0
- package/dist/three/internal.js.map +1 -0
- package/dist/three/level-set-material.d.ts +185 -0
- package/dist/three/level-set-material.js +241 -0
- package/dist/three/level-set-material.js.map +1 -0
- package/dist/three/level-set-physical-material.d.ts +154 -0
- package/dist/three/level-set-physical-material.js +253 -0
- package/dist/three/level-set-physical-material.js.map +1 -0
- package/dist/three/level-set-velocity.d.ts +94 -0
- package/dist/three/level-set-velocity.js +208 -0
- package/dist/three/level-set-velocity.js.map +1 -0
- package/dist/three/material.d.ts +324 -0
- package/dist/three/material.js +502 -0
- package/dist/three/material.js.map +1 -0
- package/dist/three/points.d.ts +140 -0
- package/dist/three/points.js +261 -0
- package/dist/three/points.js.map +1 -0
- package/dist/three/sparse-source.d.ts +165 -0
- package/dist/three/sparse-source.js +405 -0
- package/dist/three/sparse-source.js.map +1 -0
- package/dist/three/volume-source.d.ts +22 -0
- package/dist/three/volume-source.js +110 -0
- package/dist/three/volume-source.js.map +1 -0
- package/dist/tools/cpu/brick-atlas.d.ts +36 -0
- package/dist/tools/cpu/brick-atlas.js +129 -0
- package/dist/tools/cpu/brick-atlas.js.map +1 -0
- package/dist/tools/cpu/compute.d.ts +116 -0
- package/dist/tools/cpu/compute.js +239 -0
- package/dist/tools/cpu/compute.js.map +1 -0
- package/dist/tools/cpu/lean-reads.d.ts +81 -0
- package/dist/tools/cpu/lean-reads.js +262 -0
- package/dist/tools/cpu/lean-reads.js.map +1 -0
- package/dist/tools/cpu/level-set.d.ts +111 -0
- package/dist/tools/cpu/level-set.js +313 -0
- package/dist/tools/cpu/level-set.js.map +1 -0
- package/dist/tools/cpu/majorant.d.ts +265 -0
- package/dist/tools/cpu/majorant.js +541 -0
- package/dist/tools/cpu/majorant.js.map +1 -0
- package/dist/tools/cpu/march.d.ts +297 -0
- package/dist/tools/cpu/march.js +726 -0
- package/dist/tools/cpu/march.js.map +1 -0
- package/dist/tools/cpu/mesh-decimate.d.ts +124 -0
- package/dist/tools/cpu/mesh-decimate.js +1225 -0
- package/dist/tools/cpu/mesh-decimate.js.map +1 -0
- package/dist/tools/cpu/points.d.ts +29 -0
- package/dist/tools/cpu/points.js +38 -0
- package/dist/tools/cpu/points.js.map +1 -0
- package/dist/tools/cpu/probe-coords.d.ts +70 -0
- package/dist/tools/cpu/probe-coords.js +116 -0
- package/dist/tools/cpu/probe-coords.js.map +1 -0
- package/dist/tools/cpu/read-value.d.ts +44 -0
- package/dist/tools/cpu/read-value.js +351 -0
- package/dist/tools/cpu/read-value.js.map +1 -0
- package/dist/tools/cpu/sample-trilinear.d.ts +43 -0
- package/dist/tools/cpu/sample-trilinear.js +168 -0
- package/dist/tools/cpu/sample-trilinear.js.map +1 -0
- package/dist/tools/cpu/stride-tables.d.ts +56 -0
- package/dist/tools/cpu/stride-tables.generated.d.ts +1059 -0
- package/dist/tools/cpu/stride-tables.generated.js +1267 -0
- package/dist/tools/cpu/stride-tables.generated.js.map +1 -0
- package/dist/tools/cpu/stride-tables.js +78 -0
- package/dist/tools/cpu/stride-tables.js.map +1 -0
- package/dist/tools/cpu/surface-nets.d.ts +90 -0
- package/dist/tools/cpu/surface-nets.js +597 -0
- package/dist/tools/cpu/surface-nets.js.map +1 -0
- package/dist/tools/errors.d.ts +66 -0
- package/dist/tools/errors.js +67 -0
- package/dist/tools/errors.js.map +1 -0
- package/dist/tools/frame/ambient.d.ts +98 -0
- package/dist/tools/frame/ambient.js +274 -0
- package/dist/tools/frame/ambient.js.map +1 -0
- package/dist/tools/frame/blackbody.d.ts +57 -0
- package/dist/tools/frame/blackbody.js +151 -0
- package/dist/tools/frame/blackbody.js.map +1 -0
- package/dist/tools/frame/brick-cache.d.ts +165 -0
- package/dist/tools/frame/brick-cache.js +326 -0
- package/dist/tools/frame/brick-cache.js.map +1 -0
- package/dist/tools/frame/emission.d.ts +137 -0
- package/dist/tools/frame/emission.js +290 -0
- package/dist/tools/frame/emission.js.map +1 -0
- package/dist/tools/frame/environment-gpu.d.ts +111 -0
- package/dist/tools/frame/environment-gpu.js +280 -0
- package/dist/tools/frame/environment-gpu.js.map +1 -0
- package/dist/tools/frame/environment.d.ts +106 -0
- package/dist/tools/frame/environment.js +272 -0
- package/dist/tools/frame/environment.js.map +1 -0
- package/dist/tools/frame/froxel.d.ts +58 -0
- package/dist/tools/frame/froxel.js +115 -0
- package/dist/tools/frame/froxel.js.map +1 -0
- package/dist/tools/frame/grid.d.ts +392 -0
- package/dist/tools/frame/grid.js +802 -0
- package/dist/tools/frame/grid.js.map +1 -0
- package/dist/tools/frame/index.d.ts +150 -0
- package/dist/tools/frame/index.js +389 -0
- package/dist/tools/frame/index.js.map +1 -0
- package/dist/tools/frame/medium.d.ts +77 -0
- package/dist/tools/frame/medium.js +101 -0
- package/dist/tools/frame/medium.js.map +1 -0
- package/dist/tools/frame/mie-table.d.ts +6 -0
- package/dist/tools/frame/mie-table.js +16 -0
- package/dist/tools/frame/mie-table.js.map +1 -0
- package/dist/tools/frame/mie.d.ts +63 -0
- package/dist/tools/frame/mie.js +194 -0
- package/dist/tools/frame/mie.js.map +1 -0
- package/dist/tools/frame/mlp-nn.d.ts +36 -0
- package/dist/tools/frame/mlp-nn.js +159 -0
- package/dist/tools/frame/mlp-nn.js.map +1 -0
- package/dist/tools/frame/mlp-tza.d.ts +29 -0
- package/dist/tools/frame/mlp-tza.js +186 -0
- package/dist/tools/frame/mlp-tza.js.map +1 -0
- package/dist/tools/frame/mlp.d.ts +183 -0
- package/dist/tools/frame/mlp.js +434 -0
- package/dist/tools/frame/mlp.js.map +1 -0
- package/dist/tools/frame/ms-exit.d.ts +42 -0
- package/dist/tools/frame/ms-exit.js +90 -0
- package/dist/tools/frame/ms-exit.js.map +1 -0
- package/dist/tools/frame/multi-scale.d.ts +152 -0
- package/dist/tools/frame/multi-scale.js +302 -0
- package/dist/tools/frame/multi-scale.js.map +1 -0
- package/dist/tools/frame/neural-weights.d.ts +10 -0
- package/dist/tools/frame/neural-weights.js +244 -0
- package/dist/tools/frame/neural-weights.js.map +1 -0
- package/dist/tools/frame/neural.d.ts +80 -0
- package/dist/tools/frame/neural.js +150 -0
- package/dist/tools/frame/neural.js.map +1 -0
- package/dist/tools/frame/occluders.d.ts +51 -0
- package/dist/tools/frame/occluders.js +72 -0
- package/dist/tools/frame/occluders.js.map +1 -0
- package/dist/tools/frame/pyramid-layout.d.ts +55 -0
- package/dist/tools/frame/pyramid-layout.js +100 -0
- package/dist/tools/frame/pyramid-layout.js.map +1 -0
- package/dist/tools/frame/shadows.d.ts +190 -0
- package/dist/tools/frame/shadows.js +468 -0
- package/dist/tools/frame/shadows.js.map +1 -0
- package/dist/tools/frame/sparse.d.ts +147 -0
- package/dist/tools/frame/sparse.js +432 -0
- package/dist/tools/frame/sparse.js.map +1 -0
- package/dist/tools/frame/spectral-stack.d.ts +159 -0
- package/dist/tools/frame/spectral-stack.js +391 -0
- package/dist/tools/frame/spectral-stack.js.map +1 -0
- package/dist/tools/frame/spectral.d.ts +222 -0
- package/dist/tools/frame/spectral.js +572 -0
- package/dist/tools/frame/spectral.js.map +1 -0
- package/dist/tools/frame/stack.d.ts +115 -0
- package/dist/tools/frame/stack.js +290 -0
- package/dist/tools/frame/stack.js.map +1 -0
- package/dist/tools/frame/view.d.ts +131 -0
- package/dist/tools/frame/view.js +337 -0
- package/dist/tools/frame/view.js.map +1 -0
- package/dist/tools/index.d.ts +157 -0
- package/dist/tools/index.js +132 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/internal.d.ts +87 -0
- package/dist/tools/internal.js +85 -0
- package/dist/tools/internal.js.map +1 -0
- package/dist/tools/nanovdb/build-from-vdb.d.ts +59 -0
- package/dist/tools/nanovdb/build-from-vdb.js +100 -0
- package/dist/tools/nanovdb/build-from-vdb.js.map +1 -0
- package/dist/tools/nanovdb/bytes.d.ts +233 -0
- package/dist/tools/nanovdb/bytes.js +388 -0
- package/dist/tools/nanovdb/bytes.js.map +1 -0
- package/dist/tools/nanovdb/coarse-first.d.ts +78 -0
- package/dist/tools/nanovdb/coarse-first.js +92 -0
- package/dist/tools/nanovdb/coarse-first.js.map +1 -0
- package/dist/tools/nanovdb/half.d.ts +22 -0
- package/dist/tools/nanovdb/half.js +73 -0
- package/dist/tools/nanovdb/half.js.map +1 -0
- package/dist/tools/nanovdb/index.d.ts +34 -0
- package/dist/tools/nanovdb/index.js +25 -0
- package/dist/tools/nanovdb/index.js.map +1 -0
- package/dist/tools/nanovdb/inspect.d.ts +33 -0
- package/dist/tools/nanovdb/inspect.js +70 -0
- package/dist/tools/nanovdb/inspect.js.map +1 -0
- package/dist/tools/nanovdb/leaf-codec.d.ts +119 -0
- package/dist/tools/nanovdb/leaf-codec.js +356 -0
- package/dist/tools/nanovdb/leaf-codec.js.map +1 -0
- package/dist/tools/nanovdb/quantize.d.ts +72 -0
- package/dist/tools/nanovdb/quantize.js +329 -0
- package/dist/tools/nanovdb/quantize.js.map +1 -0
- package/dist/tools/nanovdb/resample.d.ts +177 -0
- package/dist/tools/nanovdb/resample.js +692 -0
- package/dist/tools/nanovdb/resample.js.map +1 -0
- package/dist/tools/nanovdb/serialize.d.ts +176 -0
- package/dist/tools/nanovdb/serialize.js +439 -0
- package/dist/tools/nanovdb/serialize.js.map +1 -0
- package/dist/tools/nanovdb/stats.d.ts +87 -0
- package/dist/tools/nanovdb/stats.js +225 -0
- package/dist/tools/nanovdb/stats.js.map +1 -0
- package/dist/tools/nanovdb/transform.d.ts +30 -0
- package/dist/tools/nanovdb/transform.js +94 -0
- package/dist/tools/nanovdb/transform.js.map +1 -0
- package/dist/tools/nanovdb/tree.d.ts +186 -0
- package/dist/tools/nanovdb/tree.js +530 -0
- package/dist/tools/nanovdb/tree.js.map +1 -0
- package/dist/tools/nanovdb/write-nvdb.d.ts +74 -0
- package/dist/tools/nanovdb/write-nvdb.js +290 -0
- package/dist/tools/nanovdb/write-nvdb.js.map +1 -0
- package/dist/tools/nvdb-file.d.ts +265 -0
- package/dist/tools/nvdb-file.js +763 -0
- package/dist/tools/nvdb-file.js.map +1 -0
- package/dist/tools/nvdb-stream.d.ts +154 -0
- package/dist/tools/nvdb-stream.js +409 -0
- package/dist/tools/nvdb-stream.js.map +1 -0
- package/dist/tools/reference/analytic.d.ts +41 -0
- package/dist/tools/reference/analytic.js +95 -0
- package/dist/tools/reference/analytic.js.map +1 -0
- package/dist/tools/reference/environment.d.ts +62 -0
- package/dist/tools/reference/environment.js +154 -0
- package/dist/tools/reference/environment.js.map +1 -0
- package/dist/tools/reference/index.d.ts +12 -0
- package/dist/tools/reference/index.js +13 -0
- package/dist/tools/reference/index.js.map +1 -0
- package/dist/tools/reference/media.d.ts +14 -0
- package/dist/tools/reference/media.js +30 -0
- package/dist/tools/reference/media.js.map +1 -0
- package/dist/tools/reference/rng.d.ts +20 -0
- package/dist/tools/reference/rng.js +30 -0
- package/dist/tools/reference/rng.js.map +1 -0
- package/dist/tools/reference/scene.d.ts +312 -0
- package/dist/tools/reference/scene.js +169 -0
- package/dist/tools/reference/scene.js.map +1 -0
- package/dist/tools/reference/tables.d.ts +98 -0
- package/dist/tools/reference/tables.js +264 -0
- package/dist/tools/reference/tables.js.map +1 -0
- package/dist/tools/reference/trace.d.ts +160 -0
- package/dist/tools/reference/trace.js +497 -0
- package/dist/tools/reference/trace.js.map +1 -0
- package/dist/tools/vdb/bit-utils.d.ts +20 -0
- package/dist/tools/vdb/bit-utils.js +42 -0
- package/dist/tools/vdb/bit-utils.js.map +1 -0
- package/dist/tools/vdb/blosc-write.d.ts +43 -0
- package/dist/tools/vdb/blosc-write.js +197 -0
- package/dist/tools/vdb/blosc-write.js.map +1 -0
- package/dist/tools/vdb/blosc.d.ts +86 -0
- package/dist/tools/vdb/blosc.js +287 -0
- package/dist/tools/vdb/blosc.js.map +1 -0
- package/dist/tools/vdb/blosclz.d.ts +33 -0
- package/dist/tools/vdb/blosclz.js +112 -0
- package/dist/tools/vdb/blosclz.js.map +1 -0
- package/dist/tools/vdb/byte-reader.d.ts +50 -0
- package/dist/tools/vdb/byte-reader.js +161 -0
- package/dist/tools/vdb/byte-reader.js.map +1 -0
- package/dist/tools/vdb/compression.d.ts +81 -0
- package/dist/tools/vdb/compression.js +260 -0
- package/dist/tools/vdb/compression.js.map +1 -0
- package/dist/tools/vdb/errors.d.ts +10 -0
- package/dist/tools/vdb/errors.js +11 -0
- package/dist/tools/vdb/errors.js.map +1 -0
- package/dist/tools/vdb/grid.d.ts +37 -0
- package/dist/tools/vdb/grid.js +153 -0
- package/dist/tools/vdb/grid.js.map +1 -0
- package/dist/tools/vdb/half-float.d.ts +9 -0
- package/dist/tools/vdb/half-float.js +24 -0
- package/dist/tools/vdb/half-float.js.map +1 -0
- package/dist/tools/vdb/index.d.ts +4 -0
- package/dist/tools/vdb/index.js +3 -0
- package/dist/tools/vdb/index.js.map +1 -0
- package/dist/tools/vdb/inflate.d.ts +24 -0
- package/dist/tools/vdb/inflate.js +334 -0
- package/dist/tools/vdb/inflate.js.map +1 -0
- package/dist/tools/vdb/lz4.d.ts +30 -0
- package/dist/tools/vdb/lz4.js +228 -0
- package/dist/tools/vdb/lz4.js.map +1 -0
- package/dist/tools/vdb/metadata.d.ts +17 -0
- package/dist/tools/vdb/metadata.js +72 -0
- package/dist/tools/vdb/metadata.js.map +1 -0
- package/dist/tools/vdb/parse.d.ts +47 -0
- package/dist/tools/vdb/parse.js +241 -0
- package/dist/tools/vdb/parse.js.map +1 -0
- package/dist/tools/vdb/point-render-data.d.ts +79 -0
- package/dist/tools/vdb/point-render-data.js +137 -0
- package/dist/tools/vdb/point-render-data.js.map +1 -0
- package/dist/tools/vdb/points.d.ts +186 -0
- package/dist/tools/vdb/points.js +835 -0
- package/dist/tools/vdb/points.js.map +1 -0
- package/dist/tools/vdb/transform.d.ts +23 -0
- package/dist/tools/vdb/transform.js +54 -0
- package/dist/tools/vdb/transform.js.map +1 -0
- package/dist/tools/vdb/tree.d.ts +111 -0
- package/dist/tools/vdb/tree.js +228 -0
- package/dist/tools/vdb/tree.js.map +1 -0
- package/dist/tools/vdb/types.d.ts +195 -0
- package/dist/tools/vdb/types.js +3 -0
- package/dist/tools/vdb/types.js.map +1 -0
- package/dist/tools/wvdb/bake.d.ts +145 -0
- package/dist/tools/wvdb/bake.js +361 -0
- package/dist/tools/wvdb/bake.js.map +1 -0
- package/dist/tools/wvdb/dense.d.ts +191 -0
- package/dist/tools/wvdb/dense.js +368 -0
- package/dist/tools/wvdb/dense.js.map +1 -0
- package/dist/tools/wvdb/format.d.ts +220 -0
- package/dist/tools/wvdb/format.js +306 -0
- package/dist/tools/wvdb/format.js.map +1 -0
- package/dist/tools/wvdb/index.d.ts +14 -0
- package/dist/tools/wvdb/index.js +15 -0
- package/dist/tools/wvdb/index.js.map +1 -0
- package/dist/tools/wvdb/level-set.d.ts +56 -0
- package/dist/tools/wvdb/level-set.js +153 -0
- package/dist/tools/wvdb/level-set.js.map +1 -0
- package/dist/tools/wvdb/nanovdb.d.ts +59 -0
- package/dist/tools/wvdb/nanovdb.js +64 -0
- package/dist/tools/wvdb/nanovdb.js.map +1 -0
- package/dist/tools/wvdb/partial.d.ts +74 -0
- package/dist/tools/wvdb/partial.js +233 -0
- package/dist/tools/wvdb/partial.js.map +1 -0
- package/dist/tools/wvdb/read.d.ts +336 -0
- package/dist/tools/wvdb/read.js +766 -0
- package/dist/tools/wvdb/read.js.map +1 -0
- package/dist/tools/wvdb/sha256.d.ts +7 -0
- package/dist/tools/wvdb/sha256.js +76 -0
- package/dist/tools/wvdb/sha256.js.map +1 -0
- package/dist/tools/wvdb/write.d.ts +149 -0
- package/dist/tools/wvdb/write.js +403 -0
- package/dist/tools/wvdb/write.js.map +1 -0
- package/package.json +83 -4
- package/vendor/LICENSE +201 -0
- package/vendor/NOTICE +19 -0
- package/vendor/VENDOR.md +100 -0
- package/vendor/pnanovdb.wgsl +1577 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `VDBPoints`: the points of a parsed point data grid as round, instanced
|
|
3
|
+
* sprites (K3.7, R1 §6 Step 7), three r187 `PointsNodeMaterial`.
|
|
4
|
+
*
|
|
5
|
+
* const grid = parseVdb(bytes).grids.find((g) => g.valueType === 'ptdataidx32');
|
|
6
|
+
* const points = new VDBPoints(vdbPointRenderData(grid), { color: 0xffffff });
|
|
7
|
+
* scene.add(points);
|
|
8
|
+
*
|
|
9
|
+
* Portions derived from mjurczyk/openvdb (MIT), commit 75e7345
|
|
10
|
+
* (`src/three-openvdb/points/webgpu/VDBPoints.js`, `points/pointsCore.js`):
|
|
11
|
+
* a `Sprite` with one instance per point (WebGPU point primitives are 1 pixel),
|
|
12
|
+
* the round alpha-tested disc, the attenuated size in pixels with a 1-pixel
|
|
13
|
+
* minimum, `Cd` colours times the material colour, the default diameter of half
|
|
14
|
+
* the mean spacing. Copyright (c) mjurczyk/openvdb contributors, MIT (see
|
|
15
|
+
* THIRD_PARTY_NOTICES.md). Changes: takes the engine-free `vdbPointRenderData` (tools)
|
|
16
|
+
* instead of decoding the grid itself; the pixel scale reads the render
|
|
17
|
+
* target's height when one is set (DIVERGES.md).
|
|
18
|
+
*
|
|
19
|
+
* The sprite size and its clip-space offset are the core's WGSL (`vdbPointSpriteSize`,
|
|
20
|
+
* `vdbPointSpriteVertex`, `core/surface/points.ts`, K6.6), the functions the raw pass
|
|
21
|
+
* `vdbCreatePointPass` calls; the vertex node calls them through `wgslFn`. The disc map stays here.
|
|
22
|
+
*
|
|
23
|
+
* Positions are world space of the grid (the point list's own transform);
|
|
24
|
+
* place them with the object's transform as any three object. The sprite sits
|
|
25
|
+
* at the origin with the points in local space, so frustum culling is off.
|
|
26
|
+
*
|
|
27
|
+
* The arrays can hold more points than are drawn (`capacity` vs `pointCount`): a prefix-ordered list (tools
|
|
28
|
+
* `vdbPointRenderData(grid, { order: 'prefix' })`) thins by count alone, and `.wvdb` points stream in LOD by LOD
|
|
29
|
+
* (K3.7b): `VDBPoints.fromWvdbGrid(header)` sizes the arrays for the grid and `addWvdbLevel(level)` writes each
|
|
30
|
+
* level a `WvdbStreamReader` decodes (only the new range is uploaded) and draws the points that have arrived.
|
|
31
|
+
*/
|
|
32
|
+
import * as THREE from "three";
|
|
33
|
+
import { InstancedBufferAttribute, PointsNodeMaterial, Sprite } from "three/webgpu";
|
|
34
|
+
import * as TSL from "three/tsl";
|
|
35
|
+
import type { WvdbPointsGrid, WvdbPointsGridHeader, WvdbPointsLevel } from "../tools/wvdb/index.js";
|
|
36
|
+
/** What `VDBPoints` draws (tools `vdbPointRenderData` returns one). */
|
|
37
|
+
export interface VDBPointsData {
|
|
38
|
+
/** World positions of the grid, xyz per point. */
|
|
39
|
+
positions: Float32Array;
|
|
40
|
+
/** Linear RGB per point (multiplied by the material colour), or null. */
|
|
41
|
+
colors?: Float32Array | null;
|
|
42
|
+
/** Points to draw (default `positions.length / 3`); the arrays may hold more (`capacity`). */
|
|
43
|
+
count?: number;
|
|
44
|
+
/** Mean point spacing in world units: the default diameter is half of it. Default 1. */
|
|
45
|
+
spacing?: number;
|
|
46
|
+
}
|
|
47
|
+
/** Options of {@link VDBPoints}: `PointsNodeMaterial` parameters plus the point diameter. */
|
|
48
|
+
export interface VDBPointsOptions extends THREE.SpriteMaterialParameters {
|
|
49
|
+
/** World diameter of a point. Default `spacing * 0.5` (a gap between neighbours). */
|
|
50
|
+
size?: number | null;
|
|
51
|
+
}
|
|
52
|
+
type ScalarUniform = ReturnType<typeof TSL.uniform> & {
|
|
53
|
+
value: number;
|
|
54
|
+
};
|
|
55
|
+
/** The 64x64 round alpha map every `VDBPoints` shares (alpha-tested at 0.5). */
|
|
56
|
+
export declare function vdbPointDiscTexture(): THREE.DataTexture;
|
|
57
|
+
/**
|
|
58
|
+
* Sprite size (pixels at view depth 1, before the half-height factor) for a world diameter: his
|
|
59
|
+
* `getAttenuatedPointSize`, `diameter * maxScale * zoom / tan(fov / 2)` (fov 50 for non-perspective cameras).
|
|
60
|
+
*/
|
|
61
|
+
export declare function vdbAttenuatedPointSize(object: THREE.Object3D, camera: THREE.Camera, diameter: number): number;
|
|
62
|
+
interface RendererSizeLike {
|
|
63
|
+
getSize(target: THREE.Vector2): THREE.Vector2;
|
|
64
|
+
getRenderTarget?(): {
|
|
65
|
+
height: number;
|
|
66
|
+
} | null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Round points of a point list as one instanced sprite (see the file comment).
|
|
70
|
+
* `count` instances; the material is a `PointsNodeMaterial` (`color`, `opacity`
|
|
71
|
+
* and the other sprite parameters apply; `Cd` multiplies the colour).
|
|
72
|
+
*/
|
|
73
|
+
export declare class VDBPoints extends Sprite {
|
|
74
|
+
/** Type flag: true. */
|
|
75
|
+
readonly isVDBPoints = true;
|
|
76
|
+
material: PointsNodeMaterial;
|
|
77
|
+
/** Mean spacing of the points (world units). */
|
|
78
|
+
spacing: number;
|
|
79
|
+
/** World diameter of a point, or null for `spacing * 0.5`. */
|
|
80
|
+
size: number | null;
|
|
81
|
+
/** Point diameter in pixels at view depth 1 (set before each render). */
|
|
82
|
+
readonly pixelScale: ScalarUniform;
|
|
83
|
+
/** The instanced position attribute (world xyz per point). */
|
|
84
|
+
readonly positionAttribute: InstancedBufferAttribute;
|
|
85
|
+
/** The instanced colour attribute (linear RGB per point), or null without colours. */
|
|
86
|
+
readonly colorAttribute: InstancedBufferAttribute | null;
|
|
87
|
+
private drawn;
|
|
88
|
+
/** `.wvdb` streaming: the grid's mean spacing over all its points, and the points written per LOD. */
|
|
89
|
+
private wvdb;
|
|
90
|
+
/**
|
|
91
|
+
* Builds the sprite from render data (tools `vdbPointRenderData`).
|
|
92
|
+
*
|
|
93
|
+
* @param data World positions (xyz triples), optional colours, count and spacing.
|
|
94
|
+
* @param options Sprite material parameters plus `size`, the world diameter of a point.
|
|
95
|
+
*/
|
|
96
|
+
constructor(data: VDBPointsData, options?: VDBPointsOptions);
|
|
97
|
+
/** Points drawn: the instance count, at most {@link capacity}. Set it to draw a prefix of the arrays. */
|
|
98
|
+
get pointCount(): number;
|
|
99
|
+
set pointCount(n: number);
|
|
100
|
+
/** Points the arrays hold: the most {@link pointCount} can be. */
|
|
101
|
+
get capacity(): number;
|
|
102
|
+
/**
|
|
103
|
+
* Writes points `[first, first + n)` of the arrays (`n = positions.length / 3`) and uploads only that range at the
|
|
104
|
+
* next render. Does not change {@link pointCount}.
|
|
105
|
+
*
|
|
106
|
+
* @param first The first point to write.
|
|
107
|
+
* @param positions xyz per point.
|
|
108
|
+
* @param colors rgb per point (n * 3 values), for a `VDBPoints` made with colours; null or omitted keeps them.
|
|
109
|
+
*/
|
|
110
|
+
writePoints(first: number, positions: Float32Array, colors?: Float32Array | null): void;
|
|
111
|
+
/**
|
|
112
|
+
* An empty `VDBPoints` sized for a `.wvdb` points grid (K3.7b): capacity = the grid's points, colours when it has
|
|
113
|
+
* them, nothing drawn. Feed it the grid's LODs with {@link addWvdbLevel} as a `WvdbStreamReader` decodes them.
|
|
114
|
+
*
|
|
115
|
+
* @param grid The grid's header record (`reader.header.grids[i]`, once the header arrived) or a decoded grid.
|
|
116
|
+
* @param options Sprite material parameters plus `size`.
|
|
117
|
+
*/
|
|
118
|
+
static fromWvdbGrid(grid: WvdbPointsGridHeader | WvdbPointsGrid, options?: VDBPointsOptions): VDBPoints;
|
|
119
|
+
/**
|
|
120
|
+
* Writes a `.wvdb` points level (a `WvdbStreamReader` event's level for this grid, complete or partial) at its
|
|
121
|
+
* `firstPoint`, uploading only the points not written before, then draws every point that has arrived in order:
|
|
122
|
+
* LOD k's points follow LODs 0..k-1, so the drawn prefix is an even subsample (every 8^(lods-1-k)-th point of the
|
|
123
|
+
* stored order). The default diameter follows: `spacing` becomes the grid's spacing times `cbrt(capacity / pointCount)`.
|
|
124
|
+
*
|
|
125
|
+
* @param level A points level of the grid this `VDBPoints` was made for ({@link fromWvdbGrid}).
|
|
126
|
+
*/
|
|
127
|
+
addWvdbLevel(level: WvdbPointsLevel): void;
|
|
128
|
+
/** The world diameter in use: `size`, or half the spacing. */
|
|
129
|
+
get diameter(): number;
|
|
130
|
+
/**
|
|
131
|
+
* Sets {@link pixelScale} for a camera and the renderer's current target (called before each render).
|
|
132
|
+
*
|
|
133
|
+
* @param renderer The renderer whose current target size gives the pixel height.
|
|
134
|
+
* @param camera The camera whose field of view (or zoom) sets the scale.
|
|
135
|
+
*/
|
|
136
|
+
updatePixelScale(renderer: RendererSizeLike, camera: THREE.Camera): void;
|
|
137
|
+
/** Frees the material (the shared disc texture stays). */
|
|
138
|
+
dispose(): void;
|
|
139
|
+
}
|
|
140
|
+
export {};
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `VDBPoints`: the points of a parsed point data grid as round, instanced
|
|
3
|
+
* sprites (K3.7, R1 §6 Step 7), three r187 `PointsNodeMaterial`.
|
|
4
|
+
*
|
|
5
|
+
* const grid = parseVdb(bytes).grids.find((g) => g.valueType === 'ptdataidx32');
|
|
6
|
+
* const points = new VDBPoints(vdbPointRenderData(grid), { color: 0xffffff });
|
|
7
|
+
* scene.add(points);
|
|
8
|
+
*
|
|
9
|
+
* Portions derived from mjurczyk/openvdb (MIT), commit 75e7345
|
|
10
|
+
* (`src/three-openvdb/points/webgpu/VDBPoints.js`, `points/pointsCore.js`):
|
|
11
|
+
* a `Sprite` with one instance per point (WebGPU point primitives are 1 pixel),
|
|
12
|
+
* the round alpha-tested disc, the attenuated size in pixels with a 1-pixel
|
|
13
|
+
* minimum, `Cd` colours times the material colour, the default diameter of half
|
|
14
|
+
* the mean spacing. Copyright (c) mjurczyk/openvdb contributors, MIT (see
|
|
15
|
+
* THIRD_PARTY_NOTICES.md). Changes: takes the engine-free `vdbPointRenderData` (tools)
|
|
16
|
+
* instead of decoding the grid itself; the pixel scale reads the render
|
|
17
|
+
* target's height when one is set (DIVERGES.md).
|
|
18
|
+
*
|
|
19
|
+
* The sprite size and its clip-space offset are the core's WGSL (`vdbPointSpriteSize`,
|
|
20
|
+
* `vdbPointSpriteVertex`, `core/surface/points.ts`, K6.6), the functions the raw pass
|
|
21
|
+
* `vdbCreatePointPass` calls; the vertex node calls them through `wgslFn`. The disc map stays here.
|
|
22
|
+
*
|
|
23
|
+
* Positions are world space of the grid (the point list's own transform);
|
|
24
|
+
* place them with the object's transform as any three object. The sprite sits
|
|
25
|
+
* at the origin with the points in local space, so frustum culling is off.
|
|
26
|
+
*
|
|
27
|
+
* The arrays can hold more points than are drawn (`capacity` vs `pointCount`): a prefix-ordered list (tools
|
|
28
|
+
* `vdbPointRenderData(grid, { order: 'prefix' })`) thins by count alone, and `.wvdb` points stream in LOD by LOD
|
|
29
|
+
* (K3.7b): `VDBPoints.fromWvdbGrid(header)` sizes the arrays for the grid and `addWvdbLevel(level)` writes each
|
|
30
|
+
* level a `WvdbStreamReader` decodes (only the new range is uploaded) and draws the points that have arrived.
|
|
31
|
+
*/
|
|
32
|
+
import * as THREE from "three";
|
|
33
|
+
import { InstancedBufferAttribute, PointsNodeMaterial, Sprite } from "three/webgpu";
|
|
34
|
+
import * as TSL from "three/tsl";
|
|
35
|
+
import { VDBError } from "../core/errors.js";
|
|
36
|
+
import { vdbPointSpriteWgsl } from "../core/surface/points.js";
|
|
37
|
+
const { cameraProjectionMatrix, code, instancedBufferAttribute, materialColor, modelViewMatrix, positionGeometry, screenDPR, uniform, vec4, viewportSize, wgslFn } = TSL;
|
|
38
|
+
/**
|
|
39
|
+
* The vertex entry: the core's sprite size (1-pixel minimum) times the device pixel ratio, then the
|
|
40
|
+
* corner's clip position (three's `PointsNodeMaterial` sprite offset, same operation order).
|
|
41
|
+
*/
|
|
42
|
+
const SPRITE_WGSL = /* wgsl */ `fn vdbThreePointSprite(clip_centre: vec4f, corner: vec2f, pixel_scale: f32, view_depth: f32, dpr: f32, viewport_size: vec2f) -> vec4f {
|
|
43
|
+
return vdbPointSpriteVertex(clip_centre, corner, vdbPointSpriteSize(pixel_scale, view_depth, 1.0) * dpr, viewport_size);
|
|
44
|
+
}`;
|
|
45
|
+
let spriteFn = null;
|
|
46
|
+
let discTexture = null;
|
|
47
|
+
/** The 64x64 round alpha map every `VDBPoints` shares (alpha-tested at 0.5). */
|
|
48
|
+
export function vdbPointDiscTexture() {
|
|
49
|
+
if (!discTexture) {
|
|
50
|
+
const size = 64;
|
|
51
|
+
const data = new Uint8Array(size * size * 4);
|
|
52
|
+
for (let y = 0; y < size; y++) {
|
|
53
|
+
for (let x = 0; x < size; x++) {
|
|
54
|
+
const dx = (x + 0.5) / size - 0.5;
|
|
55
|
+
const dy = (y + 0.5) / size - 0.5;
|
|
56
|
+
const v = Math.sqrt(dx * dx + dy * dy) <= 0.5 ? 255 : 0;
|
|
57
|
+
data.set([v, v, v, 255], (y * size + x) * 4);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
discTexture = new THREE.DataTexture(data, size, size);
|
|
61
|
+
discTexture.needsUpdate = true;
|
|
62
|
+
}
|
|
63
|
+
return discTexture;
|
|
64
|
+
}
|
|
65
|
+
const worldPosition = new THREE.Vector3();
|
|
66
|
+
const worldQuaternion = new THREE.Quaternion();
|
|
67
|
+
const worldScale = new THREE.Vector3();
|
|
68
|
+
const canvasSize = new THREE.Vector2();
|
|
69
|
+
/**
|
|
70
|
+
* Sprite size (pixels at view depth 1, before the half-height factor) for a world diameter: his
|
|
71
|
+
* `getAttenuatedPointSize`, `diameter * maxScale * zoom / tan(fov / 2)` (fov 50 for non-perspective cameras).
|
|
72
|
+
*/
|
|
73
|
+
export function vdbAttenuatedPointSize(object, camera, diameter) {
|
|
74
|
+
const perspective = camera;
|
|
75
|
+
const fov = perspective.isPerspectiveCamera ? perspective.fov : 50;
|
|
76
|
+
const zoom = camera.zoom ?? 1;
|
|
77
|
+
object.matrixWorld.decompose(worldPosition, worldQuaternion, worldScale);
|
|
78
|
+
return (diameter * Math.max(worldScale.x, worldScale.y, worldScale.z) * zoom) / Math.tan(THREE.MathUtils.degToRad(fov) * 0.5);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Round points of a point list as one instanced sprite (see the file comment).
|
|
82
|
+
* `count` instances; the material is a `PointsNodeMaterial` (`color`, `opacity`
|
|
83
|
+
* and the other sprite parameters apply; `Cd` multiplies the colour).
|
|
84
|
+
*/
|
|
85
|
+
export class VDBPoints extends Sprite {
|
|
86
|
+
/** Type flag: true. */
|
|
87
|
+
isVDBPoints = true;
|
|
88
|
+
/** Mean spacing of the points (world units). */
|
|
89
|
+
spacing;
|
|
90
|
+
/** World diameter of a point, or null for `spacing * 0.5`. */
|
|
91
|
+
size;
|
|
92
|
+
/** Point diameter in pixels at view depth 1 (set before each render). */
|
|
93
|
+
pixelScale;
|
|
94
|
+
/** The instanced position attribute (world xyz per point). */
|
|
95
|
+
positionAttribute;
|
|
96
|
+
/** The instanced colour attribute (linear RGB per point), or null without colours. */
|
|
97
|
+
colorAttribute;
|
|
98
|
+
drawn = 0;
|
|
99
|
+
/** `.wvdb` streaming: the grid's mean spacing over all its points, and the points written per LOD. */
|
|
100
|
+
wvdb = null;
|
|
101
|
+
/**
|
|
102
|
+
* Builds the sprite from render data (tools `vdbPointRenderData`).
|
|
103
|
+
*
|
|
104
|
+
* @param data World positions (xyz triples), optional colours, count and spacing.
|
|
105
|
+
* @param options Sprite material parameters plus `size`, the world diameter of a point.
|
|
106
|
+
*/
|
|
107
|
+
constructor(data, options = {}) {
|
|
108
|
+
if (!data || !(data.positions instanceof Float32Array) || data.positions.length % 3 !== 0) {
|
|
109
|
+
throw new VDBError("VDB_BAD_OPTION", "VDBPoints: data.positions must be a Float32Array of xyz triples (tools vdbPointRenderData).");
|
|
110
|
+
}
|
|
111
|
+
const count = data.count ?? data.positions.length / 3;
|
|
112
|
+
if (!Number.isInteger(count) || count < 0 || count * 3 > data.positions.length) {
|
|
113
|
+
throw new VDBError("VDB_BAD_OPTION", `VDBPoints: count ${count} does not fit ${data.positions.length / 3} positions.`);
|
|
114
|
+
}
|
|
115
|
+
if (data.colors && data.colors.length < count * 3) {
|
|
116
|
+
throw new VDBError("VDB_BAD_OPTION", "VDBPoints: colors must hold count * 3 values.");
|
|
117
|
+
}
|
|
118
|
+
const { size = null, ...materialProps } = options;
|
|
119
|
+
const capacity = data.positions.length / 3;
|
|
120
|
+
super(new PointsNodeMaterial({
|
|
121
|
+
alphaMap: vdbPointDiscTexture(),
|
|
122
|
+
alphaTest: 0.5,
|
|
123
|
+
...materialProps,
|
|
124
|
+
// sizeNode attenuates (with a 1-pixel minimum): sprites under a pixel are not drawn.
|
|
125
|
+
sizeAttenuation: false,
|
|
126
|
+
}));
|
|
127
|
+
this.spacing = data.spacing ?? 1;
|
|
128
|
+
this.size = size;
|
|
129
|
+
this.pixelScale = uniform(1);
|
|
130
|
+
this.positionAttribute = new InstancedBufferAttribute(data.positions, 3);
|
|
131
|
+
this.colorAttribute = data.colors ? new InstancedBufferAttribute(data.colors.length === capacity * 3 ? data.colors : data.colors.subarray(0, capacity * 3), 3) : null;
|
|
132
|
+
const position = instancedBufferAttribute(this.positionAttribute);
|
|
133
|
+
const view = modelViewMatrix.mul(vec4(position, 1.0));
|
|
134
|
+
const m = this.material;
|
|
135
|
+
m.positionNode = position;
|
|
136
|
+
spriteFn ??= wgslFn(SPRITE_WGSL, [code(vdbPointSpriteWgsl())]);
|
|
137
|
+
// The clip position comes from the core sprite WGSL; sizeNode is unused (vertexNode replaces three's sprite offset).
|
|
138
|
+
m.vertexNode = spriteFn({
|
|
139
|
+
clip_centre: cameraProjectionMatrix.mul(view),
|
|
140
|
+
corner: positionGeometry.xy,
|
|
141
|
+
pixel_scale: this.pixelScale,
|
|
142
|
+
view_depth: view.z.negate(),
|
|
143
|
+
dpr: screenDPR,
|
|
144
|
+
viewport_size: viewportSize,
|
|
145
|
+
});
|
|
146
|
+
m.colorNode = this.colorAttribute ? vec4(instancedBufferAttribute(this.colorAttribute), 1.0).mul(materialColor) : null;
|
|
147
|
+
m.needsUpdate = true;
|
|
148
|
+
this.pointCount = count;
|
|
149
|
+
this.frustumCulled = false;
|
|
150
|
+
this.onBeforeRender = (renderer, _scene, camera) => this.updatePixelScale(renderer, camera);
|
|
151
|
+
}
|
|
152
|
+
/** Points drawn: the instance count, at most {@link capacity}. Set it to draw a prefix of the arrays. */
|
|
153
|
+
get pointCount() {
|
|
154
|
+
return this.drawn;
|
|
155
|
+
}
|
|
156
|
+
set pointCount(n) {
|
|
157
|
+
if (!Number.isInteger(n) || n < 0 || n > this.capacity) {
|
|
158
|
+
throw new VDBError("VDB_BAD_OPTION", `VDBPoints: pointCount ${n} must be an integer in [0, ${this.capacity}].`);
|
|
159
|
+
}
|
|
160
|
+
this.drawn = n;
|
|
161
|
+
this.count = n;
|
|
162
|
+
}
|
|
163
|
+
/** Points the arrays hold: the most {@link pointCount} can be. */
|
|
164
|
+
get capacity() {
|
|
165
|
+
return this.positionAttribute.count;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Writes points `[first, first + n)` of the arrays (`n = positions.length / 3`) and uploads only that range at the
|
|
169
|
+
* next render. Does not change {@link pointCount}.
|
|
170
|
+
*
|
|
171
|
+
* @param first The first point to write.
|
|
172
|
+
* @param positions xyz per point.
|
|
173
|
+
* @param colors rgb per point (n * 3 values), for a `VDBPoints` made with colours; null or omitted keeps them.
|
|
174
|
+
*/
|
|
175
|
+
writePoints(first, positions, colors) {
|
|
176
|
+
const n = positions.length / 3;
|
|
177
|
+
if (!Number.isInteger(n) || !Number.isInteger(first) || first < 0 || first + n > this.capacity) {
|
|
178
|
+
throw new VDBError("VDB_BAD_OPTION", `VDBPoints.writePoints: points [${first}, ${first + n}) do not fit the capacity ${this.capacity}.`);
|
|
179
|
+
}
|
|
180
|
+
if (colors && (!this.colorAttribute || colors.length < n * 3)) {
|
|
181
|
+
throw new VDBError("VDB_BAD_OPTION", "VDBPoints.writePoints: colors need a VDBPoints made with colours and n * 3 values.");
|
|
182
|
+
}
|
|
183
|
+
if (n === 0)
|
|
184
|
+
return;
|
|
185
|
+
this.positionAttribute.array.set(positions, first * 3);
|
|
186
|
+
this.positionAttribute.addUpdateRange(first * 3, n * 3);
|
|
187
|
+
this.positionAttribute.needsUpdate = true;
|
|
188
|
+
if (colors && this.colorAttribute) {
|
|
189
|
+
this.colorAttribute.array.set(colors.subarray(0, n * 3), first * 3);
|
|
190
|
+
this.colorAttribute.addUpdateRange(first * 3, n * 3);
|
|
191
|
+
this.colorAttribute.needsUpdate = true;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* An empty `VDBPoints` sized for a `.wvdb` points grid (K3.7b): capacity = the grid's points, colours when it has
|
|
196
|
+
* them, nothing drawn. Feed it the grid's LODs with {@link addWvdbLevel} as a `WvdbStreamReader` decodes them.
|
|
197
|
+
*
|
|
198
|
+
* @param grid The grid's header record (`reader.header.grids[i]`, once the header arrived) or a decoded grid.
|
|
199
|
+
* @param options Sprite material parameters plus `size`.
|
|
200
|
+
*/
|
|
201
|
+
static fromWvdbGrid(grid, options = {}) {
|
|
202
|
+
if (!grid || grid.type !== "points" && grid.kind !== "points") {
|
|
203
|
+
throw new VDBError("VDB_BAD_OPTION", "VDBPoints.fromWvdbGrid: grid must be a .wvdb points grid (header record or decoded grid).");
|
|
204
|
+
}
|
|
205
|
+
const count = grid.count;
|
|
206
|
+
let spacing = grid.spacing;
|
|
207
|
+
if (!(spacing !== undefined && spacing > 0)) {
|
|
208
|
+
// The bbox estimate writeWvdb uses when no spacing is recorded: the box volume shared by the points.
|
|
209
|
+
const b = grid.bbox;
|
|
210
|
+
const volume = b ? Math.abs((b[1][0] - b[0][0]) * (b[1][1] - b[0][1]) * (b[1][2] - b[0][2])) : 0;
|
|
211
|
+
spacing = count > 0 && volume > 0 ? Math.cbrt(volume / count) : 1;
|
|
212
|
+
}
|
|
213
|
+
const points = new VDBPoints({ positions: new Float32Array(count * 3), colors: grid.colors ? new Float32Array(count * 3) : null, count: 0, spacing }, options);
|
|
214
|
+
points.wvdb = { spacing, written: new Map() };
|
|
215
|
+
return points;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Writes a `.wvdb` points level (a `WvdbStreamReader` event's level for this grid, complete or partial) at its
|
|
219
|
+
* `firstPoint`, uploading only the points not written before, then draws every point that has arrived in order:
|
|
220
|
+
* LOD k's points follow LODs 0..k-1, so the drawn prefix is an even subsample (every 8^(lods-1-k)-th point of the
|
|
221
|
+
* stored order). The default diameter follows: `spacing` becomes the grid's spacing times `cbrt(capacity / pointCount)`.
|
|
222
|
+
*
|
|
223
|
+
* @param level A points level of the grid this `VDBPoints` was made for ({@link fromWvdbGrid}).
|
|
224
|
+
*/
|
|
225
|
+
addWvdbLevel(level) {
|
|
226
|
+
if (!this.wvdb)
|
|
227
|
+
throw new VDBError("VDB_BAD_OPTION", "VDBPoints.addWvdbLevel: make the VDBPoints with VDBPoints.fromWvdbGrid(grid).");
|
|
228
|
+
if (level?.kind !== "points")
|
|
229
|
+
throw new VDBError("VDB_BAD_OPTION", "VDBPoints.addWvdbLevel: level must be a .wvdb points level.");
|
|
230
|
+
const done = this.wvdb.written.get(level.lod) ?? 0;
|
|
231
|
+
const upTo = level.pointsDecoded;
|
|
232
|
+
if (upTo > done) {
|
|
233
|
+
this.writePoints(level.firstPoint + done, level.positions.subarray(done * 3, upTo * 3), level.colors ? level.colors.subarray(done * 3, upTo * 3) : null);
|
|
234
|
+
this.wvdb.written.set(level.lod, upTo);
|
|
235
|
+
}
|
|
236
|
+
// Draw the points that have arrived without a gap (the reader decodes LODs coarse first, pages in order).
|
|
237
|
+
if (level.firstPoint <= this.pointCount)
|
|
238
|
+
this.pointCount = Math.max(this.pointCount, level.firstPoint + upTo);
|
|
239
|
+
this.spacing = this.wvdb.spacing * Math.cbrt(this.capacity / Math.max(1, this.pointCount));
|
|
240
|
+
}
|
|
241
|
+
/** The world diameter in use: `size`, or half the spacing. */
|
|
242
|
+
get diameter() {
|
|
243
|
+
return this.size ?? this.spacing * 0.5;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Sets {@link pixelScale} for a camera and the renderer's current target (called before each render).
|
|
247
|
+
*
|
|
248
|
+
* @param renderer The renderer whose current target size gives the pixel height.
|
|
249
|
+
* @param camera The camera whose field of view (or zoom) sets the scale.
|
|
250
|
+
*/
|
|
251
|
+
updatePixelScale(renderer, camera) {
|
|
252
|
+
const target = renderer.getRenderTarget?.() ?? null;
|
|
253
|
+
const height = target ? target.height : renderer.getSize(canvasSize).y;
|
|
254
|
+
this.pixelScale.value = vdbAttenuatedPointSize(this, camera, this.diameter) * height * 0.5;
|
|
255
|
+
}
|
|
256
|
+
/** Frees the material (the shared disc texture stays). */
|
|
257
|
+
dispose() {
|
|
258
|
+
this.material.dispose();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
//# sourceMappingURL=points.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"points.js","sourceRoot":"","sources":["../../src/three/points.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACpF,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAI/D,MAAM,EAAE,sBAAsB,EAAE,IAAI,EAAE,wBAAwB,EAAE,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,GAChK,GAA4C,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,GAAG,UAAU,CAAC;;EAE7B,CAAC;AACH,IAAI,QAAQ,GAAsB,IAAI,CAAC;AAsBvC,IAAI,WAAW,GAA6B,IAAI,CAAC;AAEjD,gFAAgF;AAChF,MAAM,UAAU,mBAAmB;IACjC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,EAAE,CAAC;QAChB,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,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0B,EAAE,MAAoB;QAC/D,MAAM,MAAM,GAAG,QAAQ,CAAC,eAAe,EAAE,EAAE,IAAI,IAAI,CAAC;QACpD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACvE,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,MAAM,GAAG,GAAG,CAAC;IAC7F,CAAC;IAED,0DAA0D;IAC1D,OAAO;QACL,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC1B,CAAC;CACF","sourcesContent":["/**\n * `VDBPoints`: the points of a parsed point data grid as round, instanced\n * sprites (K3.7, R1 §6 Step 7), three r187 `PointsNodeMaterial`.\n *\n * const grid = parseVdb(bytes).grids.find((g) => g.valueType === 'ptdataidx32');\n * const points = new VDBPoints(vdbPointRenderData(grid), { color: 0xffffff });\n * scene.add(points);\n *\n * Portions derived from mjurczyk/openvdb (MIT), commit 75e7345\n * (`src/three-openvdb/points/webgpu/VDBPoints.js`, `points/pointsCore.js`):\n * a `Sprite` with one instance per point (WebGPU point primitives are 1 pixel),\n * the round alpha-tested disc, the attenuated size in pixels with a 1-pixel\n * minimum, `Cd` colours times the material colour, the default diameter of half\n * the mean spacing. Copyright (c) mjurczyk/openvdb contributors, MIT (see\n * THIRD_PARTY_NOTICES.md). Changes: takes the engine-free `vdbPointRenderData` (tools)\n * instead of decoding the grid itself; the pixel scale reads the render\n * target's height when one is set (DIVERGES.md).\n *\n * The sprite size and its clip-space offset are the core's WGSL (`vdbPointSpriteSize`,\n * `vdbPointSpriteVertex`, `core/surface/points.ts`, K6.6), the functions the raw pass\n * `vdbCreatePointPass` calls; the vertex node calls them through `wgslFn`. The disc map stays here.\n *\n * Positions are world space of the grid (the point list's own transform);\n * place them with the object's transform as any three object. The sprite sits\n * at the origin with the points in local space, so frustum culling is off.\n *\n * The arrays can hold more points than are drawn (`capacity` vs `pointCount`): a prefix-ordered list (tools\n * `vdbPointRenderData(grid, { order: 'prefix' })`) thins by count alone, and `.wvdb` points stream in LOD by LOD\n * (K3.7b): `VDBPoints.fromWvdbGrid(header)` sizes the arrays for the grid and `addWvdbLevel(level)` writes each\n * level a `WvdbStreamReader` decodes (only the new range is uploaded) and draws the points that have arrived.\n */\n\nimport * as THREE from \"three\";\nimport { InstancedBufferAttribute, PointsNodeMaterial, Sprite } from \"three/webgpu\";\nimport * as TSL from \"three/tsl\";\nimport { VDBError } from \"../core/errors.js\";\nimport { vdbPointSpriteWgsl } from \"../core/surface/points.js\";\nimport type { WvdbPointsGrid, WvdbPointsGridHeader, WvdbPointsLevel } from \"../tools/wvdb/index.js\";\nimport type { VDBTslNode } from \"./grid-node.js\";\n\nconst { cameraProjectionMatrix, code, instancedBufferAttribute, materialColor, modelViewMatrix, positionGeometry, screenDPR, uniform, vec4, viewportSize, wgslFn } =\n TSL as unknown as Record<string, VDBTslNode>;\n\n/**\n * The vertex entry: the core's sprite size (1-pixel minimum) times the device pixel ratio, then the\n * corner's clip position (three's `PointsNodeMaterial` sprite offset, same operation order).\n */\nconst SPRITE_WGSL = /* wgsl */ `fn vdbThreePointSprite(clip_centre: vec4f, corner: vec2f, pixel_scale: f32, view_depth: f32, dpr: f32, viewport_size: vec2f) -> vec4f {\n return vdbPointSpriteVertex(clip_centre, corner, vdbPointSpriteSize(pixel_scale, view_depth, 1.0) * dpr, viewport_size);\n}`;\nlet spriteFn: VDBTslNode | null = null;\n\n/** What `VDBPoints` draws (tools `vdbPointRenderData` returns one). */\nexport interface VDBPointsData {\n /** World positions of the grid, xyz per point. */\n positions: Float32Array;\n /** Linear RGB per point (multiplied by the material colour), or null. */\n colors?: Float32Array | null;\n /** Points to draw (default `positions.length / 3`); the arrays may hold more (`capacity`). */\n count?: number;\n /** Mean point spacing in world units: the default diameter is half of it. Default 1. */\n spacing?: number;\n}\n\n/** Options of {@link VDBPoints}: `PointsNodeMaterial` parameters plus the point diameter. */\nexport interface VDBPointsOptions extends THREE.SpriteMaterialParameters {\n /** World diameter of a point. Default `spacing * 0.5` (a gap between neighbours). */\n size?: number | null;\n}\n\ntype ScalarUniform = ReturnType<typeof TSL.uniform> & { value: number };\n\nlet discTexture: THREE.DataTexture | null = null;\n\n/** The 64x64 round alpha map every `VDBPoints` shares (alpha-tested at 0.5). */\nexport function vdbPointDiscTexture(): THREE.DataTexture {\n if (!discTexture) {\n const size = 64;\n const data = new Uint8Array(size * size * 4);\n for (let y = 0; y < size; y++) {\n for (let x = 0; x < size; x++) {\n const dx = (x + 0.5) / size - 0.5;\n const dy = (y + 0.5) / size - 0.5;\n const v = Math.sqrt(dx * dx + dy * dy) <= 0.5 ? 255 : 0;\n data.set([v, v, v, 255], (y * size + x) * 4);\n }\n }\n discTexture = new THREE.DataTexture(data, size, size);\n discTexture.needsUpdate = true;\n }\n return discTexture;\n}\n\nconst worldPosition = new THREE.Vector3();\nconst worldQuaternion = new THREE.Quaternion();\nconst worldScale = new THREE.Vector3();\nconst canvasSize = new THREE.Vector2();\n\n/**\n * Sprite size (pixels at view depth 1, before the half-height factor) for a world diameter: his\n * `getAttenuatedPointSize`, `diameter * maxScale * zoom / tan(fov / 2)` (fov 50 for non-perspective cameras).\n */\nexport function vdbAttenuatedPointSize(object: THREE.Object3D, camera: THREE.Camera, diameter: number): number {\n const perspective = camera as THREE.PerspectiveCamera;\n const fov = perspective.isPerspectiveCamera ? perspective.fov : 50;\n const zoom = (camera as { zoom?: number }).zoom ?? 1;\n object.matrixWorld.decompose(worldPosition, worldQuaternion, worldScale);\n return (diameter * Math.max(worldScale.x, worldScale.y, worldScale.z) * zoom) / Math.tan(THREE.MathUtils.degToRad(fov) * 0.5);\n}\n\ninterface RendererSizeLike {\n getSize(target: THREE.Vector2): THREE.Vector2;\n getRenderTarget?(): { height: number } | null;\n}\n\n/**\n * Round points of a point list as one instanced sprite (see the file comment).\n * `count` instances; the material is a `PointsNodeMaterial` (`color`, `opacity`\n * and the other sprite parameters apply; `Cd` multiplies the colour).\n */\nexport class VDBPoints extends Sprite {\n /** Type flag: true. */\n readonly isVDBPoints = true;\n declare material: PointsNodeMaterial;\n /** Mean spacing of the points (world units). */\n spacing: number;\n /** World diameter of a point, or null for `spacing * 0.5`. */\n size: number | null;\n /** Point diameter in pixels at view depth 1 (set before each render). */\n readonly pixelScale: ScalarUniform;\n /** The instanced position attribute (world xyz per point). */\n readonly positionAttribute: InstancedBufferAttribute;\n /** The instanced colour attribute (linear RGB per point), or null without colours. */\n readonly colorAttribute: InstancedBufferAttribute | null;\n private drawn = 0;\n /** `.wvdb` streaming: the grid's mean spacing over all its points, and the points written per LOD. */\n private wvdb: { spacing: number; written: Map<number, number> } | null = null;\n\n /**\n * Builds the sprite from render data (tools `vdbPointRenderData`).\n *\n * @param data World positions (xyz triples), optional colours, count and spacing.\n * @param options Sprite material parameters plus `size`, the world diameter of a point.\n */\n constructor(data: VDBPointsData, options: VDBPointsOptions = {}) {\n if (!data || !(data.positions instanceof Float32Array) || data.positions.length % 3 !== 0) {\n throw new VDBError(\"VDB_BAD_OPTION\", \"VDBPoints: data.positions must be a Float32Array of xyz triples (tools vdbPointRenderData).\");\n }\n const count = data.count ?? data.positions.length / 3;\n if (!Number.isInteger(count) || count < 0 || count * 3 > data.positions.length) {\n throw new VDBError(\"VDB_BAD_OPTION\", `VDBPoints: count ${count} does not fit ${data.positions.length / 3} positions.`);\n }\n if (data.colors && data.colors.length < count * 3) {\n throw new VDBError(\"VDB_BAD_OPTION\", \"VDBPoints: colors must hold count * 3 values.\");\n }\n const { size = null, ...materialProps } = options;\n const capacity = data.positions.length / 3;\n super(\n new PointsNodeMaterial({\n alphaMap: vdbPointDiscTexture(),\n alphaTest: 0.5,\n ...materialProps,\n // sizeNode attenuates (with a 1-pixel minimum): sprites under a pixel are not drawn.\n sizeAttenuation: false,\n } as never) as never,\n );\n this.spacing = data.spacing ?? 1;\n this.size = size;\n this.pixelScale = uniform(1) as ScalarUniform;\n this.positionAttribute = new InstancedBufferAttribute(data.positions, 3);\n this.colorAttribute = data.colors ? new InstancedBufferAttribute(data.colors.length === capacity * 3 ? data.colors : data.colors.subarray(0, capacity * 3), 3) : null;\n const position = instancedBufferAttribute(this.positionAttribute);\n const view = modelViewMatrix.mul(vec4(position, 1.0));\n const m = this.material as PointsNodeMaterial & Record<string, VDBTslNode>;\n m.positionNode = position;\n spriteFn ??= wgslFn(SPRITE_WGSL, [code(vdbPointSpriteWgsl())] as never);\n // The clip position comes from the core sprite WGSL; sizeNode is unused (vertexNode replaces three's sprite offset).\n m.vertexNode = spriteFn({\n clip_centre: cameraProjectionMatrix.mul(view),\n corner: positionGeometry.xy,\n pixel_scale: this.pixelScale,\n view_depth: view.z.negate(),\n dpr: screenDPR,\n viewport_size: viewportSize,\n });\n m.colorNode = this.colorAttribute ? vec4(instancedBufferAttribute(this.colorAttribute), 1.0).mul(materialColor) : null;\n m.needsUpdate = true;\n this.pointCount = count;\n this.frustumCulled = false;\n this.onBeforeRender = (renderer, _scene, camera) => this.updatePixelScale(renderer as unknown as RendererSizeLike, camera);\n }\n\n /** Points drawn: the instance count, at most {@link capacity}. Set it to draw a prefix of the arrays. */\n get pointCount(): number {\n return this.drawn;\n }\n\n set pointCount(n: number) {\n if (!Number.isInteger(n) || n < 0 || n > this.capacity) {\n throw new VDBError(\"VDB_BAD_OPTION\", `VDBPoints: pointCount ${n} must be an integer in [0, ${this.capacity}].`);\n }\n this.drawn = n;\n (this as unknown as { count: number }).count = n;\n }\n\n /** Points the arrays hold: the most {@link pointCount} can be. */\n get capacity(): number {\n return this.positionAttribute.count;\n }\n\n /**\n * Writes points `[first, first + n)` of the arrays (`n = positions.length / 3`) and uploads only that range at the\n * next render. Does not change {@link pointCount}.\n *\n * @param first The first point to write.\n * @param positions xyz per point.\n * @param colors rgb per point (n * 3 values), for a `VDBPoints` made with colours; null or omitted keeps them.\n */\n writePoints(first: number, positions: Float32Array, colors?: Float32Array | null): void {\n const n = positions.length / 3;\n if (!Number.isInteger(n) || !Number.isInteger(first) || first < 0 || first + n > this.capacity) {\n throw new VDBError(\"VDB_BAD_OPTION\", `VDBPoints.writePoints: points [${first}, ${first + n}) do not fit the capacity ${this.capacity}.`);\n }\n if (colors && (!this.colorAttribute || colors.length < n * 3)) {\n throw new VDBError(\"VDB_BAD_OPTION\", \"VDBPoints.writePoints: colors need a VDBPoints made with colours and n * 3 values.\");\n }\n if (n === 0) return;\n (this.positionAttribute.array as Float32Array).set(positions, first * 3);\n this.positionAttribute.addUpdateRange(first * 3, n * 3);\n this.positionAttribute.needsUpdate = true;\n if (colors && this.colorAttribute) {\n (this.colorAttribute.array as Float32Array).set(colors.subarray(0, n * 3), first * 3);\n this.colorAttribute.addUpdateRange(first * 3, n * 3);\n this.colorAttribute.needsUpdate = true;\n }\n }\n\n /**\n * An empty `VDBPoints` sized for a `.wvdb` points grid (K3.7b): capacity = the grid's points, colours when it has\n * them, nothing drawn. Feed it the grid's LODs with {@link addWvdbLevel} as a `WvdbStreamReader` decodes them.\n *\n * @param grid The grid's header record (`reader.header.grids[i]`, once the header arrived) or a decoded grid.\n * @param options Sprite material parameters plus `size`.\n */\n static fromWvdbGrid(grid: WvdbPointsGridHeader | WvdbPointsGrid, options: VDBPointsOptions = {}): VDBPoints {\n if (!grid || (grid as { type?: string }).type !== \"points\" && (grid as { kind?: string }).kind !== \"points\") {\n throw new VDBError(\"VDB_BAD_OPTION\", \"VDBPoints.fromWvdbGrid: grid must be a .wvdb points grid (header record or decoded grid).\");\n }\n const count = grid.count;\n let spacing = grid.spacing;\n if (!(spacing !== undefined && spacing > 0)) {\n // The bbox estimate writeWvdb uses when no spacing is recorded: the box volume shared by the points.\n const b = grid.bbox;\n const volume = b ? Math.abs((b[1][0] - b[0][0]) * (b[1][1] - b[0][1]) * (b[1][2] - b[0][2])) : 0;\n spacing = count > 0 && volume > 0 ? Math.cbrt(volume / count) : 1;\n }\n const points = new VDBPoints(\n { positions: new Float32Array(count * 3), colors: grid.colors ? new Float32Array(count * 3) : null, count: 0, spacing },\n options,\n );\n points.wvdb = { spacing, written: new Map() };\n return points;\n }\n\n /**\n * Writes a `.wvdb` points level (a `WvdbStreamReader` event's level for this grid, complete or partial) at its\n * `firstPoint`, uploading only the points not written before, then draws every point that has arrived in order:\n * LOD k's points follow LODs 0..k-1, so the drawn prefix is an even subsample (every 8^(lods-1-k)-th point of the\n * stored order). The default diameter follows: `spacing` becomes the grid's spacing times `cbrt(capacity / pointCount)`.\n *\n * @param level A points level of the grid this `VDBPoints` was made for ({@link fromWvdbGrid}).\n */\n addWvdbLevel(level: WvdbPointsLevel): void {\n if (!this.wvdb) throw new VDBError(\"VDB_BAD_OPTION\", \"VDBPoints.addWvdbLevel: make the VDBPoints with VDBPoints.fromWvdbGrid(grid).\");\n if (level?.kind !== \"points\") throw new VDBError(\"VDB_BAD_OPTION\", \"VDBPoints.addWvdbLevel: level must be a .wvdb points level.\");\n const done = this.wvdb.written.get(level.lod) ?? 0;\n const upTo = level.pointsDecoded;\n if (upTo > done) {\n this.writePoints(level.firstPoint + done, level.positions.subarray(done * 3, upTo * 3), level.colors ? level.colors.subarray(done * 3, upTo * 3) : null);\n this.wvdb.written.set(level.lod, upTo);\n }\n // Draw the points that have arrived without a gap (the reader decodes LODs coarse first, pages in order).\n if (level.firstPoint <= this.pointCount) this.pointCount = Math.max(this.pointCount, level.firstPoint + upTo);\n this.spacing = this.wvdb.spacing * Math.cbrt(this.capacity / Math.max(1, this.pointCount));\n }\n\n /** The world diameter in use: `size`, or half the spacing. */\n get diameter(): number {\n return this.size ?? this.spacing * 0.5;\n }\n\n /**\n * Sets {@link pixelScale} for a camera and the renderer's current target (called before each render).\n *\n * @param renderer The renderer whose current target size gives the pixel height.\n * @param camera The camera whose field of view (or zoom) sets the scale.\n */\n updatePixelScale(renderer: RendererSizeLike, camera: THREE.Camera): void {\n const target = renderer.getRenderTarget?.() ?? null;\n const height = target ? target.height : renderer.getSize(canvasSize).y;\n this.pixelScale.value = vdbAttenuatedPointSize(this, camera, this.diameter) * height * 0.5;\n }\n\n /** Frees the material (the shared disc texture stays). */\n dispose(): void {\n this.material.dispose();\n }\n}\n"]}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import type { VDBGridNode } from "./grid-node.js";
|
|
2
|
+
import type { VDBVolumeSourceInfo } from "../core/source/types.js";
|
|
3
|
+
type Vec3 = [number, number, number];
|
|
4
|
+
/** The LOD strategies of the sparse source (R1 §4.3); see the file comment. */
|
|
5
|
+
export type VDBSparseLod = "none" | "coarse-pyramid" | "node-average";
|
|
6
|
+
/** The pool grid ids of the channels. `albedo`: one grey grid or three (RGB). */
|
|
7
|
+
export interface VDBSparseSourceGrids {
|
|
8
|
+
/** Pool id of the density grid. */
|
|
9
|
+
density: number;
|
|
10
|
+
/** Pool id of an optional mask grid (multiplies the density). */
|
|
11
|
+
mask?: number;
|
|
12
|
+
/** Pool id of one grey albedo grid, or three ids for RGB. */
|
|
13
|
+
albedo?: number | readonly [number, number, number];
|
|
14
|
+
/** Pool id of an optional emission (temperature) grid. */
|
|
15
|
+
emission?: number;
|
|
16
|
+
}
|
|
17
|
+
/** Inclusive voxel index box. */
|
|
18
|
+
export interface VDBIndexBox {
|
|
19
|
+
/** Smallest voxel index (inclusive). */
|
|
20
|
+
min: Vec3;
|
|
21
|
+
/** Largest voxel index (inclusive). */
|
|
22
|
+
max: Vec3;
|
|
23
|
+
}
|
|
24
|
+
/** Options of {@link vdbSparseSource}. */
|
|
25
|
+
export interface VDBSparseSourceOptions {
|
|
26
|
+
/**
|
|
27
|
+
* LOD strategy. Default `'coarse-pyramid'`, the K3.2 A/B's pick (closest to his mips, low flicker, cheap to
|
|
28
|
+
* sample; needs `images.density`); see docs/archive/handoffs/K3-2.md.
|
|
29
|
+
*/
|
|
30
|
+
lod?: VDBSparseLod;
|
|
31
|
+
/** `'coarse-pyramid'`: base level texels on the longest side at most (default 128). */
|
|
32
|
+
pyramidMax?: number;
|
|
33
|
+
/** `'none'` (default): raw floats. `'clamp01'`: clamp each density sample to [0, 1] (his 8-bit range; parity A/B). */
|
|
34
|
+
normalize?: "none" | "clamp01";
|
|
35
|
+
/** CPU copies of the grid images: the density stats read `density`. */
|
|
36
|
+
images?: {
|
|
37
|
+
density?: Uint32Array;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Density stats (`normalizeDensity` divides by `meanNonZero`). Default: computed from `images.density`.
|
|
41
|
+
* Either way they describe the image at creation; after the density grid's image changes (`pool.replace`,
|
|
42
|
+
* its `imageRevision`) the source reads the new image back from the pool and recomputes them (K3.2e; see
|
|
43
|
+
* `statsUpdates`).
|
|
44
|
+
*/
|
|
45
|
+
stats?: {
|
|
46
|
+
meanNonZero: number;
|
|
47
|
+
max: number;
|
|
48
|
+
activeVoxels: number;
|
|
49
|
+
};
|
|
50
|
+
/** Density index box the unit box covers (default: the grid's index bbox). Aux grids use their own. */
|
|
51
|
+
indexBox?: VDBIndexBox;
|
|
52
|
+
/**
|
|
53
|
+
* K3.6: index boxes the unit box covers in the aux grids (default: each grid's own index bbox). Grids converted
|
|
54
|
+
* from one dense `.wvdb` level (`wvdbDenseToNvdb`) share the texture's box (`textureIndexBox`); pass it so a
|
|
55
|
+
* sparse emission or mask channel lines up with the density (its active bbox is usually smaller).
|
|
56
|
+
*/
|
|
57
|
+
auxIndexBoxes?: Partial<Record<"mask" | "albedo" | "emission", VDBIndexBox>>;
|
|
58
|
+
/** World box (default: the density cell box through the grid's transform, as an AABB). */
|
|
59
|
+
bbox?: [Vec3, Vec3];
|
|
60
|
+
/**
|
|
61
|
+
* K3.2d: level-0 samples through `vdbSampleFast` (the 8 trilinear taps as lower-node child lookups, no
|
|
62
|
+
* tree walk per tap; bit-identical to `vdbSample`). Needs the `VDBGridNode` helper `'fastTrilinear'`.
|
|
63
|
+
* Default: on when the node has the helper.
|
|
64
|
+
*/
|
|
65
|
+
fastTrilinear?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* K3.2d: keep one accessor per shader invocation (a WGSL `var<private>`) across the samples of a march
|
|
68
|
+
* instead of a fresh one per sample, so consecutive samples reuse its cached leaf/lower/upper nodes. The
|
|
69
|
+
* values are the same either way. Default true (the K3.2d hardware A/B: with `fastTrilinear`, whose taps
|
|
70
|
+
* start from the cached lower node, 10–25% off the source passes; alone it changes little).
|
|
71
|
+
*/
|
|
72
|
+
cacheAccessor?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* G16a: follow the grids' images. When a channel grid's `imageRevision` moves (a `pool.replace`, e.g. a
|
|
75
|
+
* `vdbStreamCoarseFirst` swap from the preview to the full grid) and every channel grid is resident again, the
|
|
76
|
+
* source re-reads its index boxes, world box and transform from `pool.info`, rebuilds the coarse pyramid at the
|
|
77
|
+
* new size and bumps `version` (a `VDBFrameVolume` whose box is the source's follows it). Boxes, sizes and LOD
|
|
78
|
+
* levels are uniforms in this mode, so nothing recompiles; give the `VDBGridNode` every grid type the images will
|
|
79
|
+
* have (`types`, e.g. `VDBCoarseFirstEvent.types`): a new image of a type the node does not compile throws
|
|
80
|
+
* `VDB_TYPE_NOT_COMPILED` when the source re-reads it (it would read 0). Default false: the boxes are fixed when the
|
|
81
|
+
* source is made. Not with `indexBox`, `auxIndexBoxes` or `bbox`.
|
|
82
|
+
*/
|
|
83
|
+
followImage?: boolean;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Internal options of {@link vdbSparseSource} (`three/internal.ts`): K3.2f, the core source's brick cache (level-0
|
|
87
|
+
* density from a dense atlas of the touched 8³ blocks; core `VDBSparseSourceInternalOptions`). Opt-in until K6.T times it.
|
|
88
|
+
*/
|
|
89
|
+
export interface VDBThreeSparseSourceInternalOptions extends VDBSparseSourceOptions {
|
|
90
|
+
/** `'off'` (default), `'f32'` (bit-identical to the tree) or `'f16'` (one filtered fetch, bounded). */
|
|
91
|
+
brickCache?: "off" | "f32" | "f16";
|
|
92
|
+
/** K3.2f-e: the core source's `brickKernels`, `brickMarkStats`, `brickCapacity` and `brickBudget` (with `brickCache`). */
|
|
93
|
+
brickKernels?: "all" | "gather-marks" | "gather-only";
|
|
94
|
+
brickMarkStats?: boolean;
|
|
95
|
+
brickCapacity?: number;
|
|
96
|
+
brickBudget?: number;
|
|
97
|
+
}
|
|
98
|
+
/** K3.2f-e: the brick cache options a three source passes to its core source (absent ones keep the core defaults). */
|
|
99
|
+
export interface VDBThreeBrickOptions {
|
|
100
|
+
readonly brickKernels?: "all" | "gather-marks" | "gather-only";
|
|
101
|
+
readonly brickMarkStats?: boolean;
|
|
102
|
+
readonly brickCapacity?: number;
|
|
103
|
+
readonly brickBudget?: number;
|
|
104
|
+
}
|
|
105
|
+
/** The sparse source in three. */
|
|
106
|
+
export interface VDBThreeSparseSource extends VDBVolumeSourceInfo {
|
|
107
|
+
/** Always `"sparse"`. */
|
|
108
|
+
readonly kind: "sparse";
|
|
109
|
+
/** World box of the volume (`[min, max]`), the default `VDBFrameVolume` box. */
|
|
110
|
+
readonly bbox: [[number, number, number], [number, number, number]];
|
|
111
|
+
/** The grid node the source reads through. */
|
|
112
|
+
readonly grids: VDBGridNode;
|
|
113
|
+
/** The pool ids of the channels. */
|
|
114
|
+
readonly ids: Readonly<VDBSparseSourceGrids>;
|
|
115
|
+
/** The LOD strategy in use. */
|
|
116
|
+
readonly lod: VDBSparseLod;
|
|
117
|
+
/** Density normalization: `'clamp01'` clamps to [0, 1], `'none'` leaves it. */
|
|
118
|
+
readonly normalize: "none" | "clamp01";
|
|
119
|
+
/** The density index box the unit box covers. */
|
|
120
|
+
readonly indexBox: VDBIndexBox;
|
|
121
|
+
/** K3.2d: level 0 through `vdbSampleFast` (see the option). */
|
|
122
|
+
readonly fastTrilinear: boolean;
|
|
123
|
+
/** K3.2d: one accessor per invocation across samples (see the option). */
|
|
124
|
+
readonly cacheAccessor: boolean;
|
|
125
|
+
/** G16a: the boxes follow the grids' images (see the option). */
|
|
126
|
+
readonly followImage: boolean;
|
|
127
|
+
/** G16a: times the boxes (and the pyramid, if its size changed) were re-read after an image change. */
|
|
128
|
+
readonly layoutUpdates: number;
|
|
129
|
+
/**
|
|
130
|
+
* GPU bytes of the channel grids' pool ranges. The LOD pyramid is the core source's (demo 15:
|
|
131
|
+
* `frameRenderer.coreVolumeOf(volume).slot.source.gpuBytes`).
|
|
132
|
+
*/
|
|
133
|
+
readonly gpuBytes: {
|
|
134
|
+
readonly pool: number;
|
|
135
|
+
};
|
|
136
|
+
/** Density stats (`normalizeDensity`'s `meanNonZero`): of the density image at creation, then of the latest one read back (K3.2e). */
|
|
137
|
+
readonly stats: {
|
|
138
|
+
readonly meanNonZero: number;
|
|
139
|
+
readonly max: number;
|
|
140
|
+
readonly activeVoxels: number;
|
|
141
|
+
};
|
|
142
|
+
/** Times the stats were recomputed after an image change (K3.2e). */
|
|
143
|
+
readonly statsUpdates: number;
|
|
144
|
+
/**
|
|
145
|
+
* K3.2e: if the density grid's image changed since the stats were computed and it is resident, reads it
|
|
146
|
+
* back from the pool (own encoder, submitted) and recomputes the stats (tools' twin of the CPU path);
|
|
147
|
+
* resolves to whether it did. K6.11: nothing calls it for you (the TSL uniforms that did are deleted); `VDBFrameRenderer`
|
|
148
|
+
* copies a changed `stats` into its core slot, which otherwise re-reads the mean itself a frame or two later. Call it
|
|
149
|
+
* after `pool.update` was submitted, as `grids.update()`; await it when the first frame needs the new mean.
|
|
150
|
+
*/
|
|
151
|
+
refreshStats(): Promise<boolean>;
|
|
152
|
+
/** Drops the listeners. */
|
|
153
|
+
dispose(): void;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* A sparse volume source over pool grids (see the file comment). `grids` must be a `VDBGridNode`
|
|
157
|
+
* made with profile `'march'` and helpers `['cellBoundTrilinear', 'hddaCellEnd']` (+ `'nodeAverage'`
|
|
158
|
+
* for that LOD). The source holds no GPU object (the pool's grid buffer is the pool's).
|
|
159
|
+
*
|
|
160
|
+
* @param grids A `VDBGridNode` with profile `march` and the helpers the LOD needs.
|
|
161
|
+
* @param ids The pool ids of the density grid and optional channels.
|
|
162
|
+
* @param options LOD, normalization, boxes, pyramid and sampling options.
|
|
163
|
+
*/
|
|
164
|
+
export declare function vdbSparseSource(grids: VDBGridNode, ids: VDBSparseSourceGrids, options?: VDBSparseSourceOptions): VDBThreeSparseSource;
|
|
165
|
+
export {};
|