@pmndrs/vdb 0.1.0 → 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 +592 -2
- package/README.md +85 -37
- package/THIRD_PARTY_NOTICES.md +197 -29
- package/dist/core/compute/atlas.d.ts +10 -2
- package/dist/core/compute/atlas.js +6 -1
- package/dist/core/compute/atlas.js.map +1 -1
- package/dist/core/compute/index.d.ts +3 -3
- package/dist/core/compute/index.js +2 -2
- package/dist/core/compute/index.js.map +1 -1
- 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 +22 -7
- package/dist/core/compute/pyramid.js +22 -9
- package/dist/core/compute/pyramid.js.map +1 -1
- package/dist/core/compute/shared.d.ts +1 -0
- package/dist/core/compute/shared.js.map +1 -1
- package/dist/core/compute/stats.d.ts +10 -3
- package/dist/core/compute/stats.js +6 -1
- package/dist/core/compute/stats.js.map +1 -1
- package/dist/core/compute/value-transform.d.ts +8 -1
- package/dist/core/compute/value-transform.js +9 -3
- package/dist/core/compute/value-transform.js.map +1 -1
- package/dist/core/errors.d.ts +10 -0
- package/dist/core/errors.js +8 -0
- package/dist/core/errors.js.map +1 -1
- 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 +25 -3
- package/dist/core/index.js +23 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/internal.d.ts +17 -1
- package/dist/core/internal.js +18 -1
- package/dist/core/internal.js.map +1 -1
- package/dist/core/pool/image-header.d.ts +13 -2
- package/dist/core/pool/image-header.js +24 -5
- package/dist/core/pool/image-header.js.map +1 -1
- package/dist/core/pool/layout.d.ts +35 -1
- package/dist/core/pool/layout.js +51 -2
- package/dist/core/pool/layout.js.map +1 -1
- package/dist/core/pool/limits.d.ts +1 -0
- package/dist/core/pool/limits.js +1 -0
- package/dist/core/pool/limits.js.map +1 -1
- package/dist/core/pool/pool.d.ts +120 -15
- package/dist/core/pool/pool.js +255 -24
- package/dist/core/pool/pool.js.map +1 -1
- 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/{three → core}/sequence.d.ts +32 -2
- package/dist/{three → core}/sequence.js +24 -2
- 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 +33 -2
- package/dist/core/source/dense.js +121 -24
- package/dist/core/source/dense.js.map +1 -1
- 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 +59 -2
- package/dist/core/source/types.js.map +1 -1
- 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 +12 -3
- package/dist/core/types.js +6 -2
- package/dist/core/types.js.map +1 -1
- package/dist/core/wgsl/api.d.ts +29 -5
- package/dist/core/wgsl/api.js +110 -27
- package/dist/core/wgsl/api.js.map +1 -1
- package/dist/core/wgsl/generate.d.ts +8 -0
- package/dist/core/wgsl/generate.js +195 -22
- package/dist/core/wgsl/generate.js.map +1 -1
- 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 +5 -1
- package/dist/core/wgsl/level-set.js +11 -5
- package/dist/core/wgsl/level-set.js.map +1 -1
- 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 +2 -2
- package/dist/core/wgsl/pnanovdb.chunks.generated.js +15 -12
- package/dist/core/wgsl/pnanovdb.chunks.generated.js.map +1 -1
- package/dist/core/wgsl/types.d.ts +97 -3
- package/dist/core/wgsl/types.js.map +1 -1
- package/dist/three/coarse-first.d.ts +53 -8
- package/dist/three/coarse-first.js +24 -6
- package/dist/three/coarse-first.js.map +1 -1
- package/dist/three/compute.d.ts +12 -2
- package/dist/three/compute.js +16 -6
- package/dist/three/compute.js.map +1 -1
- package/dist/three/device.d.ts +7 -0
- package/dist/three/device.js +3 -0
- package/dist/three/device.js.map +1 -1
- 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 +64 -114
- package/dist/three/frame/emission-light.js +188 -567
- package/dist/three/frame/emission-light.js.map +1 -1
- package/dist/three/frame/index.d.ts +11 -31
- package/dist/three/frame/index.js +9 -29
- package/dist/three/frame/index.js.map +1 -1
- package/dist/three/frame/medium.d.ts +12 -0
- package/dist/three/frame/medium.js.map +1 -1
- package/dist/three/frame/renderer.d.ts +58 -454
- package/dist/three/frame/renderer.js +409 -1427
- package/dist/three/frame/renderer.js.map +1 -1
- package/dist/three/frame/spectrum.d.ts +0 -14
- package/dist/three/frame/spectrum.js +2 -23
- package/dist/three/frame/spectrum.js.map +1 -1
- package/dist/three/frame/three-internals.d.ts +3 -8
- package/dist/three/frame/three-internals.js +13 -11
- package/dist/three/frame/three-internals.js.map +1 -1
- package/dist/three/frame/volume-shadows.d.ts +93 -107
- package/dist/three/frame/volume-shadows.js +278 -631
- package/dist/three/frame/volume-shadows.js.map +1 -1
- package/dist/three/frame/volume.d.ts +91 -33
- package/dist/three/frame/volume.js +63 -51
- package/dist/three/frame/volume.js.map +1 -1
- package/dist/three/grid-node.d.ts +34 -1
- package/dist/three/grid-node.js +36 -1
- package/dist/three/grid-node.js.map +1 -1
- package/dist/three/index.d.ts +20 -11
- package/dist/three/index.js +21 -12
- package/dist/three/index.js.map +1 -1
- package/dist/three/internal.d.ts +14 -8
- package/dist/three/internal.js +11 -7
- package/dist/three/internal.js.map +1 -1
- package/dist/three/level-set-material.d.ts +81 -8
- package/dist/three/level-set-material.js +162 -125
- package/dist/three/level-set-material.js.map +1 -1
- 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 +141 -11
- package/dist/three/material.js +161 -18
- package/dist/three/material.js.map +1 -1
- package/dist/three/points.d.ts +60 -4
- package/dist/three/points.js +140 -9
- package/dist/three/points.js.map +1 -1
- package/dist/three/sparse-source.d.ts +49 -117
- package/dist/three/sparse-source.js +109 -580
- package/dist/three/sparse-source.js.map +1 -1
- package/dist/three/volume-source.d.ts +11 -156
- package/dist/three/volume-source.js +29 -272
- package/dist/three/volume-source.js.map +1 -1
- 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 +23 -4
- package/dist/tools/cpu/compute.js +35 -14
- package/dist/tools/cpu/compute.js.map +1 -1
- 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 +42 -3
- package/dist/tools/cpu/level-set.js +59 -7
- package/dist/tools/cpu/level-set.js.map +1 -1
- 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 +93 -2
- package/dist/tools/cpu/march.js +165 -14
- package/dist/tools/cpu/march.js.map +1 -1
- 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/read-value.d.ts +19 -6
- package/dist/tools/cpu/read-value.js +32 -17
- package/dist/tools/cpu/read-value.js.map +1 -1
- package/dist/tools/cpu/sample-trilinear.d.ts +17 -4
- package/dist/tools/cpu/sample-trilinear.js +19 -7
- package/dist/tools/cpu/sample-trilinear.js.map +1 -1
- package/dist/tools/cpu/stride-tables.d.ts +2 -2
- package/dist/tools/cpu/stride-tables.generated.d.ts +6 -5
- package/dist/tools/cpu/stride-tables.generated.js +7 -6
- package/dist/tools/cpu/stride-tables.generated.js.map +1 -1
- package/dist/tools/cpu/stride-tables.js +1 -1
- package/dist/tools/cpu/stride-tables.js.map +1 -1
- 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 +9 -0
- package/dist/tools/errors.js +9 -0
- package/dist/tools/errors.js.map +1 -1
- 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 +15 -0
- package/dist/tools/frame/blackbody.js +35 -0
- package/dist/tools/frame/blackbody.js.map +1 -1
- 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 +9 -0
- package/dist/tools/frame/emission.js +9 -1
- package/dist/tools/frame/emission.js.map +1 -1
- 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 +3 -2
- package/dist/tools/frame/environment.js +8 -4
- package/dist/tools/frame/environment.js.map +1 -1
- 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 +90 -0
- package/dist/tools/frame/grid.js +112 -13
- package/dist/tools/frame/grid.js.map +1 -1
- package/dist/tools/frame/index.d.ts +14 -0
- package/dist/tools/frame/index.js +45 -4
- package/dist/tools/frame/index.js.map +1 -1
- package/dist/tools/frame/medium.d.ts +16 -0
- package/dist/tools/frame/medium.js +3 -1
- package/dist/tools/frame/medium.js.map +1 -1
- package/dist/tools/frame/mie.d.ts +9 -0
- package/dist/tools/frame/mie.js +18 -0
- package/dist/tools/frame/mie.js.map +1 -1
- 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 +6 -5
- package/dist/tools/frame/neural-weights.js +234 -235
- package/dist/tools/frame/neural-weights.js.map +1 -1
- package/dist/tools/frame/neural.js +1 -1
- package/dist/tools/frame/neural.js.map +1 -1
- 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 +17 -0
- package/dist/tools/frame/pyramid-layout.js +47 -0
- package/dist/tools/frame/pyramid-layout.js.map +1 -1
- package/dist/tools/frame/shadows.d.ts +110 -0
- package/dist/tools/frame/shadows.js +286 -0
- package/dist/tools/frame/shadows.js.map +1 -1
- package/dist/tools/frame/sparse.d.ts +82 -0
- package/dist/tools/frame/sparse.js +242 -1
- package/dist/tools/frame/sparse.js.map +1 -1
- 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 +21 -2
- package/dist/tools/frame/spectral.js +30 -8
- package/dist/tools/frame/spectral.js.map +1 -1
- 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 +66 -15
- package/dist/tools/index.js +55 -11
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/internal.d.ts +58 -17
- package/dist/tools/internal.js +65 -11
- package/dist/tools/internal.js.map +1 -1
- package/dist/tools/nanovdb/build-from-vdb.d.ts +11 -2
- package/dist/tools/nanovdb/build-from-vdb.js +10 -2
- package/dist/tools/nanovdb/build-from-vdb.js.map +1 -1
- package/dist/tools/nanovdb/bytes.d.ts +17 -4
- package/dist/tools/nanovdb/bytes.js +46 -3
- package/dist/tools/nanovdb/bytes.js.map +1 -1
- package/dist/tools/nanovdb/coarse-first.d.ts +19 -3
- package/dist/tools/nanovdb/coarse-first.js +7 -1
- package/dist/tools/nanovdb/coarse-first.js.map +1 -1
- 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 +3 -1
- package/dist/tools/nanovdb/index.js +2 -1
- package/dist/tools/nanovdb/index.js.map +1 -1
- package/dist/tools/nanovdb/inspect.d.ts +10 -1
- package/dist/tools/nanovdb/inspect.js +8 -1
- package/dist/tools/nanovdb/inspect.js.map +1 -1
- package/dist/tools/nanovdb/leaf-codec.d.ts +35 -1
- package/dist/tools/nanovdb/leaf-codec.js +40 -4
- package/dist/tools/nanovdb/leaf-codec.js.map +1 -1
- package/dist/tools/nanovdb/quantize.d.ts +39 -10
- package/dist/tools/nanovdb/quantize.js +96 -44
- package/dist/tools/nanovdb/quantize.js.map +1 -1
- package/dist/tools/nanovdb/resample.d.ts +20 -3
- package/dist/tools/nanovdb/resample.js +20 -7
- package/dist/tools/nanovdb/resample.js.map +1 -1
- package/dist/tools/nanovdb/serialize.d.ts +34 -3
- package/dist/tools/nanovdb/serialize.js +51 -7
- package/dist/tools/nanovdb/serialize.js.map +1 -1
- package/dist/tools/nanovdb/stats.d.ts +34 -5
- package/dist/tools/nanovdb/stats.js +87 -11
- package/dist/tools/nanovdb/stats.js.map +1 -1
- package/dist/tools/nanovdb/transform.d.ts +4 -0
- package/dist/tools/nanovdb/transform.js +3 -0
- package/dist/tools/nanovdb/transform.js.map +1 -1
- package/dist/tools/nanovdb/tree.d.ts +14 -3
- package/dist/tools/nanovdb/tree.js +25 -13
- package/dist/tools/nanovdb/tree.js.map +1 -1
- package/dist/tools/nanovdb/write-nvdb.d.ts +47 -12
- package/dist/tools/nanovdb/write-nvdb.js +108 -28
- package/dist/tools/nanovdb/write-nvdb.js.map +1 -1
- package/dist/tools/nvdb-file.d.ts +77 -7
- package/dist/tools/nvdb-file.js +177 -20
- package/dist/tools/nvdb-file.js.map +1 -1
- package/dist/tools/nvdb-stream.d.ts +23 -7
- package/dist/tools/nvdb-stream.js +78 -34
- package/dist/tools/nvdb-stream.js.map +1 -1
- 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/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 +35 -5
- package/dist/tools/vdb/blosc.js +82 -26
- package/dist/tools/vdb/blosc.js.map +1 -1
- 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 +13 -3
- package/dist/tools/vdb/byte-reader.js +26 -4
- package/dist/tools/vdb/byte-reader.js.map +1 -1
- package/dist/tools/vdb/compression.d.ts +13 -5
- package/dist/tools/vdb/compression.js +13 -2
- package/dist/tools/vdb/compression.js.map +1 -1
- package/dist/tools/vdb/grid.js +8 -2
- package/dist/tools/vdb/grid.js.map +1 -1
- package/dist/tools/vdb/index.d.ts +2 -1
- package/dist/tools/vdb/index.js.map +1 -1
- 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.js +1 -1
- package/dist/tools/vdb/metadata.js.map +1 -1
- package/dist/tools/vdb/parse.d.ts +24 -2
- package/dist/tools/vdb/parse.js +102 -32
- package/dist/tools/vdb/parse.js.map +1 -1
- package/dist/tools/vdb/point-render-data.d.ts +49 -1
- package/dist/tools/vdb/point-render-data.js +91 -11
- package/dist/tools/vdb/point-render-data.js.map +1 -1
- package/dist/tools/vdb/points.d.ts +26 -0
- package/dist/tools/vdb/points.js +46 -5
- package/dist/tools/vdb/points.js.map +1 -1
- package/dist/tools/vdb/types.d.ts +59 -2
- package/dist/tools/vdb/types.js.map +1 -1
- package/dist/tools/wvdb/bake.d.ts +38 -9
- package/dist/tools/wvdb/bake.js +63 -13
- package/dist/tools/wvdb/bake.js.map +1 -1
- package/dist/tools/wvdb/dense.d.ts +80 -1
- package/dist/tools/wvdb/dense.js +67 -8
- package/dist/tools/wvdb/dense.js.map +1 -1
- package/dist/tools/wvdb/format.d.ts +59 -0
- package/dist/tools/wvdb/format.js +3 -0
- package/dist/tools/wvdb/format.js.map +1 -1
- package/dist/tools/wvdb/index.d.ts +1 -0
- package/dist/tools/wvdb/index.js +1 -0
- package/dist/tools/wvdb/index.js.map +1 -1
- package/dist/tools/wvdb/level-set.d.ts +10 -2
- package/dist/tools/wvdb/level-set.js.map +1 -1
- package/dist/tools/wvdb/nanovdb.d.ts +6 -1
- package/dist/tools/wvdb/nanovdb.js +5 -1
- package/dist/tools/wvdb/nanovdb.js.map +1 -1
- 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 +77 -1
- package/dist/tools/wvdb/read.js +30 -7
- package/dist/tools/wvdb/read.js.map +1 -1
- package/dist/tools/wvdb/write.d.ts +23 -1
- package/dist/tools/wvdb/write.js +8 -1
- package/dist/tools/wvdb/write.js.map +1 -1
- package/package.json +2 -1
- package/vendor/VENDOR.md +21 -6
- package/vendor/pnanovdb.wgsl +52 -14
- package/dist/three/frame/blackbody.d.ts +0 -42
- package/dist/three/frame/blackbody.js +0 -74
- package/dist/three/frame/blackbody.js.map +0 -1
- package/dist/three/frame/chunks.d.ts +0 -157
- package/dist/three/frame/chunks.js +0 -559
- package/dist/three/frame/chunks.js.map +0 -1
- package/dist/three/frame/density-material.d.ts +0 -53
- package/dist/three/frame/density-material.js +0 -353
- package/dist/three/frame/density-material.js.map +0 -1
- package/dist/three/frame/environment-grid-material.d.ts +0 -21
- package/dist/three/frame/environment-grid-material.js +0 -184
- package/dist/three/frame/environment-grid-material.js.map +0 -1
- package/dist/three/frame/environment-material.d.ts +0 -22
- package/dist/three/frame/environment-material.js +0 -87
- package/dist/three/frame/environment-material.js.map +0 -1
- package/dist/three/frame/grid-mip-material.d.ts +0 -12
- package/dist/three/frame/grid-mip-material.js +0 -61
- package/dist/three/frame/grid-mip-material.js.map +0 -1
- package/dist/three/frame/inject-material.d.ts +0 -56
- package/dist/three/frame/inject-material.js +0 -424
- package/dist/three/frame/inject-material.js.map +0 -1
- package/dist/three/frame/integrate-material.d.ts +0 -26
- package/dist/three/frame/integrate-material.js +0 -198
- package/dist/three/frame/integrate-material.js.map +0 -1
- package/dist/three/frame/layout.d.ts +0 -34
- package/dist/three/frame/layout.js +0 -48
- package/dist/three/frame/layout.js.map +0 -1
- package/dist/three/frame/lighting-material.d.ts +0 -41
- package/dist/three/frame/lighting-material.js +0 -257
- package/dist/three/frame/lighting-material.js.map +0 -1
- package/dist/three/frame/lights.d.ts +0 -11
- package/dist/three/frame/lights.js +0 -16
- package/dist/three/frame/lights.js.map +0 -1
- package/dist/three/frame/neural.d.ts +0 -14
- package/dist/three/frame/neural.js +0 -105
- package/dist/three/frame/neural.js.map +0 -1
- package/dist/three/frame/phase.d.ts +0 -44
- package/dist/three/frame/phase.js +0 -80
- package/dist/three/frame/phase.js.map +0 -1
- package/dist/three/frame/shadow-density-material.d.ts +0 -30
- package/dist/three/frame/shadow-density-material.js +0 -123
- package/dist/three/frame/shadow-density-material.js.map +0 -1
- package/dist/three/frame/temporal-material.d.ts +0 -29
- package/dist/three/frame/temporal-material.js +0 -152
- package/dist/three/frame/temporal-material.js.map +0 -1
- package/dist/three/frame/transmittance-material.d.ts +0 -31
- package/dist/three/frame/transmittance-material.js +0 -315
- package/dist/three/frame/transmittance-material.js.map +0 -1
- package/dist/three/frame/view.d.ts +0 -103
- package/dist/three/frame/view.js +0 -296
- package/dist/three/frame/view.js.map +0 -1
- package/dist/three/frame/volume-shadow-material.d.ts +0 -36
- package/dist/three/frame/volume-shadow-material.js +0 -128
- package/dist/three/frame/volume-shadow-material.js.map +0 -1
- package/dist/three/sequence.js.map +0 -1
package/dist/three/points.js
CHANGED
|
@@ -16,15 +16,33 @@
|
|
|
16
16
|
* instead of decoding the grid itself; the pixel scale reads the render
|
|
17
17
|
* target's height when one is set (DIVERGES.md).
|
|
18
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
|
+
*
|
|
19
23
|
* Positions are world space of the grid (the point list's own transform);
|
|
20
24
|
* place them with the object's transform as any three object. The sprite sits
|
|
21
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.
|
|
22
31
|
*/
|
|
23
32
|
import * as THREE from "three";
|
|
24
33
|
import { InstancedBufferAttribute, PointsNodeMaterial, Sprite } from "three/webgpu";
|
|
25
34
|
import * as TSL from "three/tsl";
|
|
26
35
|
import { VDBError } from "../core/errors.js";
|
|
27
|
-
|
|
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;
|
|
28
46
|
let discTexture = null;
|
|
29
47
|
/** The 64x64 round alpha map every `VDBPoints` shares (alpha-tested at 0.5). */
|
|
30
48
|
export function vdbPointDiscTexture() {
|
|
@@ -65,17 +83,27 @@ export function vdbAttenuatedPointSize(object, camera, diameter) {
|
|
|
65
83
|
* and the other sprite parameters apply; `Cd` multiplies the colour).
|
|
66
84
|
*/
|
|
67
85
|
export class VDBPoints extends Sprite {
|
|
86
|
+
/** Type flag: true. */
|
|
68
87
|
isVDBPoints = true;
|
|
69
|
-
/** Points drawn. */
|
|
70
|
-
pointCount;
|
|
71
88
|
/** Mean spacing of the points (world units). */
|
|
72
89
|
spacing;
|
|
73
90
|
/** World diameter of a point, or null for `spacing * 0.5`. */
|
|
74
91
|
size;
|
|
75
92
|
/** Point diameter in pixels at view depth 1 (set before each render). */
|
|
76
93
|
pixelScale;
|
|
94
|
+
/** The instanced position attribute (world xyz per point). */
|
|
77
95
|
positionAttribute;
|
|
96
|
+
/** The instanced colour attribute (linear RGB per point), or null without colours. */
|
|
78
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
|
+
*/
|
|
79
107
|
constructor(data, options = {}) {
|
|
80
108
|
if (!data || !(data.positions instanceof Float32Array) || data.positions.length % 3 !== 0) {
|
|
81
109
|
throw new VDBError("VDB_BAD_OPTION", "VDBPoints: data.positions must be a Float32Array of xyz triples (tools vdbPointRenderData).");
|
|
@@ -88,6 +116,7 @@ export class VDBPoints extends Sprite {
|
|
|
88
116
|
throw new VDBError("VDB_BAD_OPTION", "VDBPoints: colors must hold count * 3 values.");
|
|
89
117
|
}
|
|
90
118
|
const { size = null, ...materialProps } = options;
|
|
119
|
+
const capacity = data.positions.length / 3;
|
|
91
120
|
super(new PointsNodeMaterial({
|
|
92
121
|
alphaMap: vdbPointDiscTexture(),
|
|
93
122
|
alphaTest: 0.5,
|
|
@@ -95,28 +124,130 @@ export class VDBPoints extends Sprite {
|
|
|
95
124
|
// sizeNode attenuates (with a 1-pixel minimum): sprites under a pixel are not drawn.
|
|
96
125
|
sizeAttenuation: false,
|
|
97
126
|
}));
|
|
98
|
-
this.pointCount = count;
|
|
99
127
|
this.spacing = data.spacing ?? 1;
|
|
100
128
|
this.size = size;
|
|
101
129
|
this.pixelScale = uniform(1);
|
|
102
130
|
this.positionAttribute = new InstancedBufferAttribute(data.positions, 3);
|
|
103
|
-
this.colorAttribute = data.colors ? new InstancedBufferAttribute(data.colors, 3) : null;
|
|
131
|
+
this.colorAttribute = data.colors ? new InstancedBufferAttribute(data.colors.length === capacity * 3 ? data.colors : data.colors.subarray(0, capacity * 3), 3) : null;
|
|
104
132
|
const position = instancedBufferAttribute(this.positionAttribute);
|
|
105
|
-
const
|
|
133
|
+
const view = modelViewMatrix.mul(vec4(position, 1.0));
|
|
106
134
|
const m = this.material;
|
|
107
135
|
m.positionNode = position;
|
|
108
|
-
|
|
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
|
+
});
|
|
109
146
|
m.colorNode = this.colorAttribute ? vec4(instancedBufferAttribute(this.colorAttribute), 1.0).mul(materialColor) : null;
|
|
110
147
|
m.needsUpdate = true;
|
|
111
|
-
this.
|
|
148
|
+
this.pointCount = count;
|
|
112
149
|
this.frustumCulled = false;
|
|
113
150
|
this.onBeforeRender = (renderer, _scene, camera) => this.updatePixelScale(renderer, camera);
|
|
114
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
|
+
}
|
|
115
241
|
/** The world diameter in use: `size`, or half the spacing. */
|
|
116
242
|
get diameter() {
|
|
117
243
|
return this.size ?? this.spacing * 0.5;
|
|
118
244
|
}
|
|
119
|
-
/**
|
|
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
|
+
*/
|
|
120
251
|
updatePixelScale(renderer, camera) {
|
|
121
252
|
const target = renderer.getRenderTarget?.() ?? null;
|
|
122
253
|
const height = target ? target.height : renderer.getSize(canvasSize).y;
|
package/dist/three/points.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"points.js","sourceRoot":"","sources":["../../src/three/points.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;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;AAG7C,MAAM,EAAE,wBAAwB,EAAE,aAAa,EAAE,GAAG,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,GAA4C,CAAC;AAsBtI,IAAI,WAAW,GAA6B,IAAI,CAAC;AAEjD,gFAAgF;AAChF,MAAM,UAAU,mBAAmB;IACjC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,EAAE,CAA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;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 * 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\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 type { VDBTslNode } from \"./grid-node.js\";\n\nconst { instancedBufferAttribute, materialColor, max, modelViewMatrix, uniform, vec4 } = TSL as unknown as Record<string, VDBTslNode>;\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`). */\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 readonly isVDBPoints = true;\n declare material: PointsNodeMaterial;\n /** Points drawn. */\n pointCount: number;\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 readonly positionAttribute: InstancedBufferAttribute;\n readonly colorAttribute: InstancedBufferAttribute | null;\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 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.pointCount = count;\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, 3) : null;\n const position = instancedBufferAttribute(this.positionAttribute);\n const viewDepth = modelViewMatrix.mul(vec4(position, 1.0)).z.negate();\n const m = this.material as PointsNodeMaterial & Record<string, VDBTslNode>;\n m.positionNode = position;\n m.sizeNode = max((this.pixelScale as VDBTslNode).div(viewDepth), 1.0);\n m.colorNode = this.colorAttribute ? vec4(instancedBufferAttribute(this.colorAttribute), 1.0).mul(materialColor) : null;\n m.needsUpdate = true;\n (this as unknown as { count: number }).count = count;\n this.frustumCulled = false;\n this.onBeforeRender = (renderer, _scene, camera) => this.updatePixelScale(renderer as unknown as RendererSizeLike, camera);\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 /** Sets {@link pixelScale} for a camera and the renderer's current target (called before each render). */\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"]}
|
|
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,EA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GAAG,IAAI,CAAC,CAAC;QAC9G,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAC7F,CAAC;IAED,8DAA8D;IAC9D,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,QAA0B,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"]}
|
|
@@ -1,62 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* dense `.wvdb` source, so `VDBFrameVolume` renders NanoVDB grids.
|
|
4
|
-
*
|
|
5
|
-
* const grids = new VDBGridNode(renderer, pool, { profile: "march", helpers: ["cellBoundTrilinear", "hddaCellEnd", "nodeAverage", "fastTrilinear"] });
|
|
6
|
-
* const source = vdbSparseSource(grids, { density: id }, { lod: "coarse-pyramid", images: { density: image } });
|
|
7
|
-
* const volume = new VDBFrameVolume(source, { extinction: 100 }); // box: the grid's world box
|
|
8
|
-
*
|
|
9
|
-
* Positions are his local unit box [-0.5, 0.5]³; uvw = local + 0.5 (+ offset, wrapped) maps onto the
|
|
10
|
-
* channel grid's index cell box `[min − ½, max + ½]` (voxel centres at integers), so uvw
|
|
11
|
-
* (i + 0.5) / N lands on voxel min + i as on a dense texel centre. The sample position is clamped to
|
|
12
|
-
* `[min, max]` (his clamp-to-edge). Level 0 is the pool's trilinear `vdbSample`; with the node helper
|
|
13
|
-
* `'fastTrilinear'` (recommended, K3.2d) it is `vdbSampleFast` through one accessor per shader invocation
|
|
14
|
-
* (`cacheAccessor`): the same values, 1.5–2× faster on the hardware GPU (docs/archive/handoffs/K3-2d.md).
|
|
15
|
-
*
|
|
16
|
-
* LOD (`lod`, his `sampleExtinction(localPos, lod)` at lod ≥ 1; R1 §4.3):
|
|
17
|
-
* - `'none'`: level 0 always (no prefilter; aliases when a froxel spans many voxels). lodLevels 0.
|
|
18
|
-
* - `'coarse-pyramid'` (default, the K3.2 A/B pick): a dense r16f pyramid from L₀ = max(1, ⌈log2(maxTexels / pyramidMax)⌉):
|
|
19
|
-
* the base is a box resample of the grid, the levels above it his box mip atlas. lod in (0, L₀)
|
|
20
|
-
* blends level 0 toward L₀; lod ≥ L₀ samples the pyramid as his mip atlas. GPU bytes: ~2 B × (base
|
|
21
|
-
* + atlas) texels. Built on the GPU from the pool grid by default (`pyramidBuild: 'gpu'`, K3.2a: the
|
|
22
|
-
* core's `vdbCreateBoxPyramid`, no CPU image needed) and rebuilt when the grid's image changes
|
|
23
|
-
* (`pool.replace`: a sequence frame), checked once per render that samples it; `'cpu'` keeps the
|
|
24
|
-
* K3.2 path (`@pmndrs/vdb/tools` `vdbBoxPyramid` from `images.density`, static). Both give the same
|
|
25
|
-
* texels to ≤ 1 f16 ulp (e2e/k3-pyramid.spec.ts).
|
|
26
|
-
* - `'node-average'`: no extra memory: trilinear over the node averages (`vdbNodeAverage`) at
|
|
27
|
-
* level 3 (leaves, the exact 8³ box mean for fog leaves) and level 7 (lower nodes, the mean of
|
|
28
|
-
* their active voxels); lod in (0, 3) blends level 0 → 3, (3, 7) blends 3 → 7. Needs stats.
|
|
29
|
-
*
|
|
30
|
-
* HDDA: `skipEmpty` lets a march jump samples that are provably 0 (`VDBFrameVolume` `hdda`, default
|
|
31
|
-
* off since D30 / D31: it slowed the shadow march on Apple GPUs; the image is the same either way).
|
|
32
|
-
*
|
|
33
|
-
* Following the image (`followImage`, G16a): the index boxes, world box and pyramid are fixed when the source is
|
|
34
|
-
* made unless it follows the grids' images. Then a `pool.replace` that changes a channel grid's box (a coarse-first
|
|
35
|
-
* swap: the preview, then the full grid in the same id) is re-read from `pool.info` once the new image is resident:
|
|
36
|
-
* new box uniforms, a new GPU pyramid of the new size (its textures swapped into the same texture nodes), the LOD
|
|
37
|
-
* range as a uniform, and a new `version`, which a `VDBFrameVolume` follows with its box. No shader is rebuilt, and the
|
|
38
|
-
* pyramid kernels of every type the `VDBGridNode` decodes are compiled up front.
|
|
39
|
-
*
|
|
40
|
-
* Mask, albedo and emission grids (optional, scalar; albedo may be three grids for RGB) are read at
|
|
41
|
-
* level 0 only. One VDB module per shader: every grid goes through the one `VDBGridNode`.
|
|
42
|
-
*/
|
|
43
|
-
import * as THREE from "three";
|
|
44
|
-
import { type VDBBoxPyramidGpu } from "../core/compute/pyramid.js";
|
|
45
|
-
import { type VDBGridNode, type VDBTslNode } from "./grid-node.js";
|
|
46
|
-
import { type VDBThreeSourceFactory, type VDBVolumeUniforms } from "./volume-source.js";
|
|
1
|
+
import type { VDBGridNode } from "./grid-node.js";
|
|
2
|
+
import type { VDBVolumeSourceInfo } from "../core/source/types.js";
|
|
47
3
|
type Vec3 = [number, number, number];
|
|
48
4
|
/** The LOD strategies of the sparse source (R1 §4.3); see the file comment. */
|
|
49
5
|
export type VDBSparseLod = "none" | "coarse-pyramid" | "node-average";
|
|
50
6
|
/** The pool grid ids of the channels. `albedo`: one grey grid or three (RGB). */
|
|
51
7
|
export interface VDBSparseSourceGrids {
|
|
8
|
+
/** Pool id of the density grid. */
|
|
52
9
|
density: number;
|
|
10
|
+
/** Pool id of an optional mask grid (multiplies the density). */
|
|
53
11
|
mask?: number;
|
|
12
|
+
/** Pool id of one grey albedo grid, or three ids for RGB. */
|
|
54
13
|
albedo?: number | readonly [number, number, number];
|
|
14
|
+
/** Pool id of an optional emission (temperature) grid. */
|
|
55
15
|
emission?: number;
|
|
56
16
|
}
|
|
57
17
|
/** Inclusive voxel index box. */
|
|
58
18
|
export interface VDBIndexBox {
|
|
19
|
+
/** Smallest voxel index (inclusive). */
|
|
59
20
|
min: Vec3;
|
|
21
|
+
/** Largest voxel index (inclusive). */
|
|
60
22
|
max: Vec3;
|
|
61
23
|
}
|
|
62
24
|
/** Options of {@link vdbSparseSource}. */
|
|
@@ -68,16 +30,9 @@ export interface VDBSparseSourceOptions {
|
|
|
68
30
|
lod?: VDBSparseLod;
|
|
69
31
|
/** `'coarse-pyramid'`: base level texels on the longest side at most (default 128). */
|
|
70
32
|
pyramidMax?: number;
|
|
71
|
-
/**
|
|
72
|
-
* `'coarse-pyramid'`: where the pyramid is built. `'gpu'` (default, K3.2a): a compute pass over the
|
|
73
|
-
* pool grid on the renderer's device (the core's `vdbCreateBoxPyramid`), rebuilt when the grid's
|
|
74
|
-
* `imageRevision` changes; needs an initialized WebGPURenderer behind the `VDBGridNode`. `'cpu'`:
|
|
75
|
-
* `vdbBoxPyramid` from `images.density` (the K3.2 path, static; the GPU build's twin).
|
|
76
|
-
*/
|
|
77
|
-
pyramidBuild?: "gpu" | "cpu";
|
|
78
33
|
/** `'none'` (default): raw floats. `'clamp01'`: clamp each density sample to [0, 1] (his 8-bit range; parity A/B). */
|
|
79
34
|
normalize?: "none" | "clamp01";
|
|
80
|
-
/** CPU copies of the grid images: the density stats
|
|
35
|
+
/** CPU copies of the grid images: the density stats read `density`. */
|
|
81
36
|
images?: {
|
|
82
37
|
density?: Uint32Array;
|
|
83
38
|
};
|
|
@@ -123,44 +78,46 @@ export interface VDBSparseSourceOptions {
|
|
|
123
78
|
* levels are uniforms in this mode, so nothing recompiles; give the `VDBGridNode` every grid type the images will
|
|
124
79
|
* have (`types`, e.g. `VDBCoarseFirstEvent.types`): a new image of a type the node does not compile throws
|
|
125
80
|
* `VDB_TYPE_NOT_COMPILED` when the source re-reads it (it would read 0). Default false: the boxes are fixed when the
|
|
126
|
-
* source is made. Not with `indexBox`, `auxIndexBoxes
|
|
81
|
+
* source is made. Not with `indexBox`, `auxIndexBoxes` or `bbox`.
|
|
127
82
|
*/
|
|
128
83
|
followImage?: boolean;
|
|
129
84
|
}
|
|
130
|
-
/**
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
readonly
|
|
146
|
-
|
|
147
|
-
readonly
|
|
148
|
-
|
|
149
|
-
readonly map: THREE.Data3DTexture;
|
|
150
|
-
readonly mip: THREE.Data3DTexture | null;
|
|
151
|
-
/** The core GPU pyramid writing into `map` / `mip` (GPU path), else null. */
|
|
152
|
-
readonly gpu: VDBBoxPyramidGpu | null;
|
|
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;
|
|
153
104
|
}
|
|
154
105
|
/** The sparse source in three. */
|
|
155
|
-
export interface VDBThreeSparseSource extends
|
|
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. */
|
|
156
112
|
readonly grids: VDBGridNode;
|
|
113
|
+
/** The pool ids of the channels. */
|
|
157
114
|
readonly ids: Readonly<VDBSparseSourceGrids>;
|
|
115
|
+
/** The LOD strategy in use. */
|
|
158
116
|
readonly lod: VDBSparseLod;
|
|
117
|
+
/** Density normalization: `'clamp01'` clamps to [0, 1], `'none'` leaves it. */
|
|
159
118
|
readonly normalize: "none" | "clamp01";
|
|
160
119
|
/** The density index box the unit box covers. */
|
|
161
120
|
readonly indexBox: VDBIndexBox;
|
|
162
|
-
/** `'coarse-pyramid'` only: the pyramid and its textures. */
|
|
163
|
-
readonly pyramid: VDBSparsePyramid | null;
|
|
164
121
|
/** K3.2d: level 0 through `vdbSampleFast` (see the option). */
|
|
165
122
|
readonly fastTrilinear: boolean;
|
|
166
123
|
/** K3.2d: one accessor per invocation across samples (see the option). */
|
|
@@ -170,16 +127,12 @@ export interface VDBThreeSparseSource extends VDBThreeSourceFactory {
|
|
|
170
127
|
/** G16a: times the boxes (and the pyramid, if its size changed) were re-read after an image change. */
|
|
171
128
|
readonly layoutUpdates: number;
|
|
172
129
|
/**
|
|
173
|
-
* GPU bytes
|
|
174
|
-
*
|
|
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`).
|
|
175
132
|
*/
|
|
176
133
|
readonly gpuBytes: {
|
|
177
134
|
readonly pool: number;
|
|
178
|
-
readonly pyramid: number;
|
|
179
|
-
readonly pyramidScratch: number;
|
|
180
135
|
};
|
|
181
|
-
/** GPU pyramid builds recorded so far (the first, then one per image change). */
|
|
182
|
-
readonly pyramidBuilds: number;
|
|
183
136
|
/** Density stats (`normalizeDensity`'s `meanNonZero`): of the density image at creation, then of the latest one read back (K3.2e). */
|
|
184
137
|
readonly stats: {
|
|
185
138
|
readonly meanNonZero: number;
|
|
@@ -191,43 +144,22 @@ export interface VDBThreeSparseSource extends VDBThreeSourceFactory {
|
|
|
191
144
|
/**
|
|
192
145
|
* K3.2e: if the density grid's image changed since the stats were computed and it is resident, reads it
|
|
193
146
|
* back from the pool (own encoder, submitted) and recomputes the stats (tools' twin of the CPU path);
|
|
194
|
-
* resolves to whether it did.
|
|
195
|
-
*
|
|
196
|
-
* submitted, as `grids.update()
|
|
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.
|
|
197
150
|
*/
|
|
198
151
|
refreshStats(): Promise<boolean>;
|
|
199
|
-
/**
|
|
200
|
-
* GPU path: rebuilds the pyramid now (own encoder, submitted) if the density grid's image changed
|
|
201
|
-
* since the last build and it is resident; returns whether it did. Renders that sample the pyramid
|
|
202
|
-
* call it themselves; call it after `pool.update` was submitted, as `grids.update()`.
|
|
203
|
-
*/
|
|
204
|
-
refreshPyramid(): boolean;
|
|
205
|
-
/**
|
|
206
|
-
* The source's WGSL helpers as `wgslFn` nodes (including the grid module), for probes and tests:
|
|
207
|
-
* `vdbFrameNodeAverage(g, p, dim) -> f32` (CPU twin `tools` `vdbFrameNodeAverageSample`) and
|
|
208
|
-
* `vdbFrameSkipEmpty(g, o, d, t0, t1, cutoff, dilate) -> vec2f` (twin `vdbFrameSkipEmpty`).
|
|
209
|
-
*/
|
|
210
|
-
nodeAverageFn(): VDBTslNode;
|
|
211
|
-
skipEmptyFn(): VDBTslNode;
|
|
152
|
+
/** Drops the listeners. */
|
|
212
153
|
dispose(): void;
|
|
213
154
|
}
|
|
214
|
-
/** Uniforms of a sparse source: his `VDBVolumeUniforms` plus the channel boxes and pyramid sizes. */
|
|
215
|
-
export interface VDBSparseVolumeUniforms extends VDBVolumeUniforms {
|
|
216
|
-
/** Per channel: index min and size of the index box (voxels). */
|
|
217
|
-
readonly boxes: Readonly<Record<"density" | "mask" | "albedo" | "emission", {
|
|
218
|
-
min: VDBTslNode;
|
|
219
|
-
size: VDBTslNode;
|
|
220
|
-
} | null>>;
|
|
221
|
-
readonly pyramidLevel: VDBTslNode;
|
|
222
|
-
readonly pyramidLevels: VDBTslNode;
|
|
223
|
-
readonly pyramidTexels: VDBTslNode;
|
|
224
|
-
readonly pyramidAtlasSize: VDBTslNode;
|
|
225
|
-
}
|
|
226
155
|
/**
|
|
227
156
|
* A sparse volume source over pool grids (see the file comment). `grids` must be a `VDBGridNode`
|
|
228
157
|
* made with profile `'march'` and helpers `['cellBoundTrilinear', 'hddaCellEnd']` (+ `'nodeAverage'`
|
|
229
|
-
* for that LOD). The source holds no
|
|
230
|
-
*
|
|
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.
|
|
231
163
|
*/
|
|
232
164
|
export declare function vdbSparseSource(grids: VDBGridNode, ids: VDBSparseSourceGrids, options?: VDBSparseSourceOptions): VDBThreeSparseSource;
|
|
233
165
|
export {};
|