@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,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binding the core frame renderer's `GPUTexture`s into three r187 (K6.1, design §6; owner Q2): a stand-in
|
|
3
|
+
* per output, three's `ExternalTexture` (r187: `backend.createTexture` takes `sourceTexture` as the GPU
|
|
4
|
+
* texture and `destroyTexture` never destroys it) flagged `is3DTexture`, so a `texture3D()` node binds
|
|
5
|
+
* the core texture with a 3D view. When `outputs.version` moves, a new stand-in replaces the old one (three
|
|
6
|
+
* cannot re-point an initialized ExternalTexture) and the node's `value` swaps, which rebuilds its bind
|
|
7
|
+
* group. Once per backend a self-test puts a throwaway texture through the same path and checks three
|
|
8
|
+
* took it as given and did not destroy it, else `VDB_ENGINE_MISMATCH`.
|
|
9
|
+
*/
|
|
10
|
+
import { ExternalTexture } from "three";
|
|
11
|
+
interface RendererLike {
|
|
12
|
+
readonly backend: object;
|
|
13
|
+
initTexture(texture: object): void;
|
|
14
|
+
}
|
|
15
|
+
/** Label of the once-per-backend self-test texture (1³; tests that count textures skip it). */
|
|
16
|
+
export declare const VDB_THREE_CORE_TEXTURE_SELF_TEST_LABEL = "@pmndrs/vdb/three core-texture self-test";
|
|
17
|
+
/** How three views a core texture: a 3D texture (froxels, probes), a 2d-array (volume shadow maps) or a cube (point maps). */
|
|
18
|
+
export type VDBCoreTextureKind = "3d" | "2d-array" | "cube";
|
|
19
|
+
/** A three stand-in for a core texture (K6.1: 3D; K6.5: 2d-array and cube views of the volume shadow maps). */
|
|
20
|
+
export declare function vdbCoreTextureStandIn(gpu: GPUTexture, kind?: VDBCoreTextureKind): ExternalTexture;
|
|
21
|
+
/**
|
|
22
|
+
* Checks once per backend that three binds an ExternalTexture's `sourceTexture` as given and never destroys
|
|
23
|
+
* it (dispose included).
|
|
24
|
+
*
|
|
25
|
+
* @throws VDBError `VDB_ENGINE_MISMATCH` when three's internals differ.
|
|
26
|
+
*/
|
|
27
|
+
export declare function vdbCoreTextureSelfTest(renderer: RendererLike, device: GPUDevice): void;
|
|
28
|
+
/** One core output bound into three: `texture` follows the core texture (a new stand-in when it changes). */
|
|
29
|
+
export declare class VDBCoreTextureBinding {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(kind?: VDBCoreTextureKind);
|
|
32
|
+
/** The current stand-in (null before the first {@link set}). */
|
|
33
|
+
get texture(): ExternalTexture | null;
|
|
34
|
+
/** The core texture of the current stand-in (null before the first {@link set}). */
|
|
35
|
+
get gpu(): GPUTexture | null;
|
|
36
|
+
/** Points the binding at `gpu`; returns true when the stand-in changed (swap the node's `value`). */
|
|
37
|
+
set(gpu: GPUTexture): boolean;
|
|
38
|
+
/** Drops the stand-in (the core texture belongs to the core renderer). */
|
|
39
|
+
dispose(): void;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binding the core frame renderer's `GPUTexture`s into three r187 (K6.1, design §6; owner Q2): a stand-in
|
|
3
|
+
* per output, three's `ExternalTexture` (r187: `backend.createTexture` takes `sourceTexture` as the GPU
|
|
4
|
+
* texture and `destroyTexture` never destroys it) flagged `is3DTexture`, so a `texture3D()` node binds
|
|
5
|
+
* the core texture with a 3D view. When `outputs.version` moves, a new stand-in replaces the old one (three
|
|
6
|
+
* cannot re-point an initialized ExternalTexture) and the node's `value` swaps, which rebuilds its bind
|
|
7
|
+
* group. Once per backend a self-test puts a throwaway texture through the same path and checks three
|
|
8
|
+
* took it as given and did not destroy it, else `VDB_ENGINE_MISMATCH`.
|
|
9
|
+
*/
|
|
10
|
+
import { ClampToEdgeWrapping, CubeReflectionMapping, ExternalTexture, LinearFilter, REVISION } from "three";
|
|
11
|
+
import { VDBError } from "../../core/errors.js";
|
|
12
|
+
/** Label of the once-per-backend self-test texture (1³; tests that count textures skip it). */
|
|
13
|
+
export const VDB_THREE_CORE_TEXTURE_SELF_TEST_LABEL = "@pmndrs/vdb/three core-texture self-test";
|
|
14
|
+
const selfTested = new WeakMap();
|
|
15
|
+
const mismatch = (what) => new VDBError("VDB_ENGINE_MISMATCH", `three adapter: three r${REVISION} ${what}. The core frame renderer binds its GPUTextures into three through ExternalTexture ` +
|
|
16
|
+
"(written against three r187); this three version is unsupported for VDBFrameRenderer.");
|
|
17
|
+
/** A three stand-in for a core texture (K6.1: 3D; K6.5: 2d-array and cube views of the volume shadow maps). */
|
|
18
|
+
export function vdbCoreTextureStandIn(gpu, kind = "3d") {
|
|
19
|
+
const t = new ExternalTexture(gpu);
|
|
20
|
+
const f = t;
|
|
21
|
+
if (kind === "3d")
|
|
22
|
+
f.is3DTexture = true;
|
|
23
|
+
else if (kind === "2d-array")
|
|
24
|
+
f.isArrayTexture = true;
|
|
25
|
+
else {
|
|
26
|
+
f.isCubeTexture = true;
|
|
27
|
+
// K6.8a: a cube's mapping (three's default is UVMapping): CubeTextureNode logs "Mapping not supported" for any other
|
|
28
|
+
t.mapping = CubeReflectionMapping;
|
|
29
|
+
}
|
|
30
|
+
f.wrapR = ClampToEdgeWrapping;
|
|
31
|
+
t.wrapS = t.wrapT = ClampToEdgeWrapping;
|
|
32
|
+
t.minFilter = t.magFilter = LinearFilter;
|
|
33
|
+
t.generateMipmaps = false;
|
|
34
|
+
t.flipY = false;
|
|
35
|
+
t.name = gpu.label;
|
|
36
|
+
f.image = { width: gpu.width, height: gpu.height, depth: gpu.depthOrArrayLayers };
|
|
37
|
+
return t;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Checks once per backend that three binds an ExternalTexture's `sourceTexture` as given and never destroys
|
|
41
|
+
* it (dispose included).
|
|
42
|
+
*
|
|
43
|
+
* @throws VDBError `VDB_ENGINE_MISMATCH` when three's internals differ.
|
|
44
|
+
*/
|
|
45
|
+
export function vdbCoreTextureSelfTest(renderer, device) {
|
|
46
|
+
const backend = renderer.backend;
|
|
47
|
+
const cached = selfTested.get(backend);
|
|
48
|
+
if (cached === true)
|
|
49
|
+
return;
|
|
50
|
+
if (cached)
|
|
51
|
+
throw cached;
|
|
52
|
+
let error = null;
|
|
53
|
+
const dummy = device.createTexture({ label: VDB_THREE_CORE_TEXTURE_SELF_TEST_LABEL, size: [1, 1, 1], dimension: "3d", format: "rgba16float", usage: 0x04 /* TEXTURE_BINDING */ });
|
|
54
|
+
const realDestroy = dummy.destroy;
|
|
55
|
+
let destroyedByThree = false;
|
|
56
|
+
dummy.destroy = () => {
|
|
57
|
+
destroyedByThree = true;
|
|
58
|
+
};
|
|
59
|
+
try {
|
|
60
|
+
if (typeof backend.get !== "function" || typeof renderer.initTexture !== "function")
|
|
61
|
+
throw mismatch("has no backend.get or renderer.initTexture");
|
|
62
|
+
const t = vdbCoreTextureStandIn(dummy);
|
|
63
|
+
renderer.initTexture(t);
|
|
64
|
+
if (backend.get(t).texture !== dummy)
|
|
65
|
+
error = mismatch("did not bind an ExternalTexture's sourceTexture as its GPU texture");
|
|
66
|
+
t.dispose();
|
|
67
|
+
if (!error && destroyedByThree)
|
|
68
|
+
error = mismatch("destroyed an ExternalTexture's sourceTexture on dispose");
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
error = e instanceof VDBError ? e : mismatch(`failed the core-texture self-test (${e instanceof Error ? e.message : String(e)})`);
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
dummy.destroy = realDestroy;
|
|
75
|
+
dummy.destroy();
|
|
76
|
+
}
|
|
77
|
+
selfTested.set(backend, error ?? true);
|
|
78
|
+
if (error)
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
/** One core output bound into three: `texture` follows the core texture (a new stand-in when it changes). */
|
|
82
|
+
export class VDBCoreTextureBinding {
|
|
83
|
+
#gpu = null;
|
|
84
|
+
#standIn = null;
|
|
85
|
+
#kind;
|
|
86
|
+
constructor(kind = "3d") {
|
|
87
|
+
this.#kind = kind;
|
|
88
|
+
}
|
|
89
|
+
/** The current stand-in (null before the first {@link set}). */
|
|
90
|
+
get texture() {
|
|
91
|
+
return this.#standIn;
|
|
92
|
+
}
|
|
93
|
+
/** The core texture of the current stand-in (null before the first {@link set}). */
|
|
94
|
+
get gpu() {
|
|
95
|
+
return this.#gpu;
|
|
96
|
+
}
|
|
97
|
+
/** Points the binding at `gpu`; returns true when the stand-in changed (swap the node's `value`). */
|
|
98
|
+
set(gpu) {
|
|
99
|
+
if (gpu === this.#gpu)
|
|
100
|
+
return false;
|
|
101
|
+
// ExternalTexture.dispose never destroys the core texture (the self-test checked it); the core retires it.
|
|
102
|
+
this.#standIn?.dispose();
|
|
103
|
+
this.#gpu = gpu;
|
|
104
|
+
this.#standIn = vdbCoreTextureStandIn(gpu, this.#kind);
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
/** Drops the stand-in (the core texture belongs to the core renderer). */
|
|
108
|
+
dispose() {
|
|
109
|
+
this.#standIn?.dispose();
|
|
110
|
+
this.#standIn = null;
|
|
111
|
+
this.#gpu = null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=core-textures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-textures.js","sourceRoot":"","sources":["../../../src/three/frame/core-textures.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5G,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAUhD,+FAA+F;AAC/F,MAAM,CAAC,MAAM,sCAAsC,GAAG,0CAA0C,CAAC;AAEjG,MAAM,UAAU,GAAG,IAAI,OAAO,EAA2B,CAAC;AAE1D,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAChC,IAAI,QAAQ,CACV,qBAAqB,EACrB,yBAAyB,QAAQ,IAAI,IAAI,qFAAqF;IAC5H,uFAAuF,CAC1F,CAAC;AAKJ,+GAA+G;AAC/G,MAAM,UAAU,qBAAqB,CAAC,GAAe,EAAE,OAA2B,IAAI;IACpF,MAAM,CAAC,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,CAAC,GAAG,CAAuC,CAAC;IAClD,IAAI,IAAI,KAAK,IAAI;QAAE,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC;SACnC,IAAI,IAAI,KAAK,UAAU;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,GAAsB,IAAI,CAAC;IAC/B,QAAQ,GAA2B,IAAI,CAAC;IAC/B,KAAK,CAAqB;IAEnC,YAAY,OAA2B,IAAI;QACzC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED,gEAAgE;IAChE,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,oFAAoF;IACpF,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,qGAAqG;IACrG,GAAG,CAAC,GAAe;QACjB,IAAI,GAAG,KAAK,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAC;QACpC,2GAA2G;QAC3G,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,qBAAqB,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0EAA0E;IAC1E,OAAO;QACL,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF","sourcesContent":["/**\n * Binding the core frame renderer's `GPUTexture`s into three r187 (K6.1, design §6; owner Q2): a stand-in\n * per output, three's `ExternalTexture` (r187: `backend.createTexture` takes `sourceTexture` as the GPU\n * texture and `destroyTexture` never destroys it) flagged `is3DTexture`, so a `texture3D()` node binds\n * the core texture with a 3D view. When `outputs.version` moves, a new stand-in replaces the old one (three\n * cannot re-point an initialized ExternalTexture) and the node's `value` swaps, which rebuilds its bind\n * group. Once per backend a self-test puts a throwaway texture through the same path and checks three\n * took it as given and did not destroy it, else `VDB_ENGINE_MISMATCH`.\n */\n\nimport { ClampToEdgeWrapping, CubeReflectionMapping, ExternalTexture, LinearFilter, REVISION } from \"three\";\nimport { VDBError } from \"../../core/errors.js\";\n\ninterface BackendLike {\n get(object: object): Record<string, unknown>;\n}\ninterface RendererLike {\n readonly backend: object;\n initTexture(texture: object): void;\n}\n\n/** Label of the once-per-backend self-test texture (1³; tests that count textures skip it). */\nexport const VDB_THREE_CORE_TEXTURE_SELF_TEST_LABEL = \"@pmndrs/vdb/three core-texture self-test\";\n\nconst selfTested = new WeakMap<object, true | VDBError>();\n\nconst mismatch = (what: string) =>\n new VDBError(\n \"VDB_ENGINE_MISMATCH\",\n `three adapter: three r${REVISION} ${what}. The core frame renderer binds its GPUTextures into three through ExternalTexture ` +\n \"(written against three r187); this three version is unsupported for VDBFrameRenderer.\",\n );\n\n/** How three views a core texture: a 3D texture (froxels, probes), a 2d-array (volume shadow maps) or a cube (point maps). */\nexport type VDBCoreTextureKind = \"3d\" | \"2d-array\" | \"cube\";\n\n/** A three stand-in for a core texture (K6.1: 3D; K6.5: 2d-array and cube views of the volume shadow maps). */\nexport function vdbCoreTextureStandIn(gpu: GPUTexture, kind: VDBCoreTextureKind = \"3d\"): ExternalTexture {\n const t = new ExternalTexture(gpu);\n const f = t as unknown as Record<string, unknown>;\n if (kind === \"3d\") f.is3DTexture = true;\n else if (kind === \"2d-array\") f.isArrayTexture = true;\n else {\n f.isCubeTexture = true;\n // K6.8a: a cube's mapping (three's default is UVMapping): CubeTextureNode logs \"Mapping not supported\" for any other\n t.mapping = CubeReflectionMapping;\n }\n f.wrapR = ClampToEdgeWrapping;\n t.wrapS = t.wrapT = ClampToEdgeWrapping;\n t.minFilter = t.magFilter = LinearFilter;\n t.generateMipmaps = false;\n t.flipY = false;\n t.name = gpu.label;\n f.image = { width: gpu.width, height: gpu.height, depth: gpu.depthOrArrayLayers };\n return t;\n}\n\n/**\n * Checks once per backend that three binds an ExternalTexture's `sourceTexture` as given and never destroys\n * it (dispose included).\n *\n * @throws VDBError `VDB_ENGINE_MISMATCH` when three's internals differ.\n */\nexport function vdbCoreTextureSelfTest(renderer: RendererLike, device: GPUDevice): void {\n const backend = renderer.backend as BackendLike;\n const cached = selfTested.get(backend);\n if (cached === true) return;\n if (cached) throw cached;\n let error: VDBError | null = null;\n const dummy = device.createTexture({ label: VDB_THREE_CORE_TEXTURE_SELF_TEST_LABEL, size: [1, 1, 1], dimension: \"3d\", format: \"rgba16float\", usage: 0x04 /* TEXTURE_BINDING */ });\n const realDestroy = dummy.destroy;\n let destroyedByThree = false;\n (dummy as { destroy: () => void }).destroy = () => {\n destroyedByThree = true;\n };\n try {\n if (typeof backend.get !== \"function\" || typeof renderer.initTexture !== \"function\") throw mismatch(\"has no backend.get or renderer.initTexture\");\n const t = vdbCoreTextureStandIn(dummy);\n renderer.initTexture(t);\n if (backend.get(t).texture !== dummy) error = mismatch(\"did not bind an ExternalTexture's sourceTexture as its GPU texture\");\n t.dispose();\n if (!error && destroyedByThree) error = mismatch(\"destroyed an ExternalTexture's sourceTexture on dispose\");\n } catch (e) {\n error = e instanceof VDBError ? e : mismatch(`failed the core-texture self-test (${e instanceof Error ? e.message : String(e)})`);\n } finally {\n (dummy as { destroy: () => void }).destroy = realDestroy;\n dummy.destroy();\n }\n selfTested.set(backend, error ?? true);\n if (error) throw error;\n}\n\n/** One core output bound into three: `texture` follows the core texture (a new stand-in when it changes). */\nexport class VDBCoreTextureBinding {\n #gpu: GPUTexture | null = null;\n #standIn: ExternalTexture | null = null;\n readonly #kind: VDBCoreTextureKind;\n\n constructor(kind: VDBCoreTextureKind = \"3d\") {\n this.#kind = kind;\n }\n\n /** The current stand-in (null before the first {@link set}). */\n get texture(): ExternalTexture | null {\n return this.#standIn;\n }\n\n /** The core texture of the current stand-in (null before the first {@link set}). */\n get gpu(): GPUTexture | null {\n return this.#gpu;\n }\n\n /** Points the binding at `gpu`; returns true when the stand-in changed (swap the node's `value`). */\n set(gpu: GPUTexture): boolean {\n if (gpu === this.#gpu) return false;\n // ExternalTexture.dispose never destroys the core texture (the self-test checked it); the core retires it.\n this.#standIn?.dispose();\n this.#gpu = gpu;\n this.#standIn = vdbCoreTextureStandIn(gpu, this.#kind);\n return true;\n }\n\n /** Drops the stand-in (the core texture belongs to the core renderer). */\n dispose(): void {\n this.#standIn?.dispose();\n this.#standIn = null;\n this.#gpu = null;\n }\n}\n"]}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* K3.6 / K6.5: light from the emissive grids of every visible `VDBFrameVolume` (his `FrameEmissionLight`). Add one to
|
|
3
|
+
* the scene; three's lit node materials (`MeshStandardMaterial`, `MeshLambertMaterial`, …) receive it as irradiance,
|
|
4
|
+
* like a light probe. The core frame renderer of the scene's volumes draws the emitters and L1 irradiance probes (up to
|
|
5
|
+
* 4 cascades of ≤ 32³) when a volume or the cascades changed; a lit pixel reads 6 texels (12 near a cascade side).
|
|
6
|
+
*
|
|
7
|
+
* const light = new VDBFrameEmissionLight({ intensity: 25, resolution: 32 });
|
|
8
|
+
* scene.add(light); // volumes need an emission channel; colour: VDBFrameVolume `emissionColor`
|
|
9
|
+
*
|
|
10
|
+
* K6.8b: a lit pixel runs the core's `vdbEmissionIrradiance(probes, smp, grid, world, normal)` (`vdbEmissionProbeWgsl()`,
|
|
11
|
+
* twin `vdbFrameEmissionLookup` + `vdbFrameEmissionIrradiance`) through a `wgslFn`: `probes` is the core's probe stack
|
|
12
|
+
* (`outputs.emissionProbes.texture`, a 3D texture stand-in) and `grid` its `VdbEmissionGrid` buffer
|
|
13
|
+
* (`outputs.emissionProbes.grid`, bound through a storage stand-in and unpacked from `array<vec4u>`; the core rewrites it
|
|
14
|
+
* each update). The texture and storage nodes are made once; their `value` follows the core (placeholders while it has no
|
|
15
|
+
* probes: a 1³ texture and a zero grid, which lights nothing). three r187 re-reads a plain material's texture and storage
|
|
16
|
+
* bindings only on a full refresh, so a new core object (a new probe resolution, a released stack, another frame
|
|
17
|
+
* renderer) also rebuilds the receivers: the light keeps `castShadow` on (it casts no shadow) and its node bumps
|
|
18
|
+
* `version`, which three's lights cache key holds for a `castShadow` light. They rebuild at their next render; the core
|
|
19
|
+
* keeps the old stack alive two more updates (the K6.10 finding-8 class).
|
|
20
|
+
*/
|
|
21
|
+
import * as THREE from "three";
|
|
22
|
+
import { AnalyticLightNode } from "three/webgpu";
|
|
23
|
+
import { VDBCoreTextureBinding } from "./core-textures.js";
|
|
24
|
+
import type { VDBFrameEmissionProbes } from "../../core/frame/types.js";
|
|
25
|
+
/**
|
|
26
|
+
* The irradiance at a lit point from the core's probe cascades (`vdbEmissionIrradiance`: the finest cascade that holds
|
|
27
|
+
* it, blended into the next one near its sides; past the last cascade its clamped edge probes fall off with distance
|
|
28
|
+
* squared), times the light's colour × intensity.
|
|
29
|
+
*/
|
|
30
|
+
export declare class VDBFrameEmissionLightNode extends AnalyticLightNode<THREE.Light> {
|
|
31
|
+
#private;
|
|
32
|
+
static get type(): string;
|
|
33
|
+
/** Unique per light node: names the storage binding and the WGSL functions. */
|
|
34
|
+
readonly k: number;
|
|
35
|
+
constructor(light?: VDBFrameEmissionLight | null);
|
|
36
|
+
private get emissionLight();
|
|
37
|
+
/** The probe stack and grid bound now (null before the first receiver build); tests and harnesses. @internal */
|
|
38
|
+
get bound(): {
|
|
39
|
+
texture: GPUTexture | null;
|
|
40
|
+
grid: GPUBuffer;
|
|
41
|
+
placeholder: boolean;
|
|
42
|
+
} | null;
|
|
43
|
+
updateBefore(frame: never): boolean | undefined;
|
|
44
|
+
update(frame: never): boolean | undefined;
|
|
45
|
+
setup(builder: never): null;
|
|
46
|
+
dispose(): void;
|
|
47
|
+
}
|
|
48
|
+
/** Props of {@link VDBFrameEmissionLight} (his `FrameEmissionLight` props; same names and defaults). */
|
|
49
|
+
export interface VDBFrameEmissionLightProps {
|
|
50
|
+
/** Light colour (default white). */
|
|
51
|
+
color?: THREE.ColorRepresentation;
|
|
52
|
+
/** Light intensity, a multiplier of the volumes' emitted light (default 1). */
|
|
53
|
+
intensity?: number;
|
|
54
|
+
/** Probes on each axis of each cascade, 2–32 (default 16). */
|
|
55
|
+
resolution?: number;
|
|
56
|
+
/** Size of the last cascade as a multiple of the box of all emitting volumes; past it light falls off with distance² (default 3). */
|
|
57
|
+
range?: number;
|
|
58
|
+
/** 1: one grid for all volumes. Up to 4: finer grids around the camera (default 1). */
|
|
59
|
+
cascades?: number;
|
|
60
|
+
/** The finer cascades cover this distance from the camera (default 512). */
|
|
61
|
+
distance?: number;
|
|
62
|
+
/** Steps of each ray in a volume (default 24). */
|
|
63
|
+
steps?: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Light that lights lit meshes with the emission of emissive `VDBFrameVolume`s (his `FrameEmissionLight`): the core
|
|
67
|
+
* frame renderer of the scene's volumes draws the emitters and the probe cascades; this light's node reads them. Add
|
|
68
|
+
* it to the scene.
|
|
69
|
+
*/
|
|
70
|
+
export declare class VDBFrameEmissionLight extends THREE.Light {
|
|
71
|
+
/** Type flag. */
|
|
72
|
+
readonly isVDBFrameEmissionLight: true;
|
|
73
|
+
/** Probes on each axis of each cascade, 2 to 32. */
|
|
74
|
+
resolution: number;
|
|
75
|
+
/** Size of the last cascade as a multiple of the box of all emitting volumes. */
|
|
76
|
+
range: number;
|
|
77
|
+
/** Probe grid cascades, 1 to 4 (1: one grid for all volumes). */
|
|
78
|
+
cascades: number;
|
|
79
|
+
/** Distance from the camera that the finer cascades cover. */
|
|
80
|
+
distance: number;
|
|
81
|
+
/** Steps of each ray in a volume (rounded, at least 1). */
|
|
82
|
+
steps: number;
|
|
83
|
+
/** Minimum corner of each cascade in world space (valid for the first `cascadeCount`). */
|
|
84
|
+
readonly cascadeMin: THREE.Vector3[];
|
|
85
|
+
/** Size of each cascade in world space (valid for the first `cascadeCount`). */
|
|
86
|
+
readonly cascadeSize: THREE.Vector3[];
|
|
87
|
+
/** Cascades in use after the last probe update. */
|
|
88
|
+
cascadeCount: number;
|
|
89
|
+
/** Probes on each axis of each cascade after the last update. */
|
|
90
|
+
probeResolution: number;
|
|
91
|
+
/** World centre of the probe grid after the last update. */
|
|
92
|
+
readonly probeCenter: THREE.Vector3;
|
|
93
|
+
/** Emissive volumes in the last update. */
|
|
94
|
+
emitterCount: number;
|
|
95
|
+
/** Volumes drawn in the last probe update and whether the probes were drawn (not his; tests and timing). */
|
|
96
|
+
readonly lastUpdate: {
|
|
97
|
+
directions: number;
|
|
98
|
+
probes: boolean;
|
|
99
|
+
};
|
|
100
|
+
/** The core's probes after the last update (null: none). */
|
|
101
|
+
coreProbes: VDBFrameEmissionProbes | null;
|
|
102
|
+
/** @internal The stand-in of the core probe stack. */
|
|
103
|
+
readonly coreBinding: VDBCoreTextureBinding;
|
|
104
|
+
/**
|
|
105
|
+
* Makes the light with its probe grid settings.
|
|
106
|
+
* @param props {@link VDBFrameEmissionLightProps}; all fields optional.
|
|
107
|
+
*/
|
|
108
|
+
constructor(props?: VDBFrameEmissionLightProps);
|
|
109
|
+
/** Steps of each ray, rounded and at least 1. */
|
|
110
|
+
getSteps(): number;
|
|
111
|
+
/**
|
|
112
|
+
* The core frame of this render (the frame renderer of the scene's first visible volume) draws the emitters and the
|
|
113
|
+
* probes; this light copies the probe grid for its node. The light node calls it before the lit meshes of each render.
|
|
114
|
+
*/
|
|
115
|
+
updateProbes(renderer: object, scene: THREE.Object3D, viewCamera: THREE.Camera): void;
|
|
116
|
+
dispose(): void;
|
|
117
|
+
}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
+
// src/three-openvdb/frame/core/FrameEmissionLight.js L1–287 (FrameEmissionLightBase: props, probe cascades);
|
|
3
|
+
// src/three-openvdb/frame/webgpu/FrameEmissionLight.js L59–658 (FrameEmissionLightNode: the probe lookup with the
|
|
4
|
+
// cascade blend and the falloff past the last cascade; FrameEmissionLight: props, the node registration).
|
|
5
|
+
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
6
|
+
// Changes: TypeScript; K6.8: the emitters and probes are the core frame renderer's (its emission kernels, a stacked 3D
|
|
7
|
+
// texture read with hardware trilinear); this light carries the settings and lights meshes; K6.8b: the lookup is the
|
|
8
|
+
// core's own WGSL (`vdbEmissionIrradiance` of `vdbEmissionProbeWgsl()`) through a `wgslFn`, the probe grid read from the
|
|
9
|
+
// core's buffer through a storage stand-in, instead of a TSL port; every three r187 internal goes through
|
|
10
|
+
// `three-internals.ts` or the stand-in self-tests (VDB_ENGINE_MISMATCH on another three). Divergences: DIVERGES.md (K3.6,
|
|
11
|
+
// K6.5, K6.8b rows).
|
|
12
|
+
/**
|
|
13
|
+
* K3.6 / K6.5: light from the emissive grids of every visible `VDBFrameVolume` (his `FrameEmissionLight`). Add one to
|
|
14
|
+
* the scene; three's lit node materials (`MeshStandardMaterial`, `MeshLambertMaterial`, …) receive it as irradiance,
|
|
15
|
+
* like a light probe. The core frame renderer of the scene's volumes draws the emitters and L1 irradiance probes (up to
|
|
16
|
+
* 4 cascades of ≤ 32³) when a volume or the cascades changed; a lit pixel reads 6 texels (12 near a cascade side).
|
|
17
|
+
*
|
|
18
|
+
* const light = new VDBFrameEmissionLight({ intensity: 25, resolution: 32 });
|
|
19
|
+
* scene.add(light); // volumes need an emission channel; colour: VDBFrameVolume `emissionColor`
|
|
20
|
+
*
|
|
21
|
+
* K6.8b: a lit pixel runs the core's `vdbEmissionIrradiance(probes, smp, grid, world, normal)` (`vdbEmissionProbeWgsl()`,
|
|
22
|
+
* twin `vdbFrameEmissionLookup` + `vdbFrameEmissionIrradiance`) through a `wgslFn`: `probes` is the core's probe stack
|
|
23
|
+
* (`outputs.emissionProbes.texture`, a 3D texture stand-in) and `grid` its `VdbEmissionGrid` buffer
|
|
24
|
+
* (`outputs.emissionProbes.grid`, bound through a storage stand-in and unpacked from `array<vec4u>`; the core rewrites it
|
|
25
|
+
* each update). The texture and storage nodes are made once; their `value` follows the core (placeholders while it has no
|
|
26
|
+
* probes: a 1³ texture and a zero grid, which lights nothing). three r187 re-reads a plain material's texture and storage
|
|
27
|
+
* bindings only on a full refresh, so a new core object (a new probe resolution, a released stack, another frame
|
|
28
|
+
* renderer) also rebuilds the receivers: the light keeps `castShadow` on (it casts no shadow) and its node bumps
|
|
29
|
+
* `version`, which three's lights cache key holds for a `castShadow` light. They rebuild at their next render; the core
|
|
30
|
+
* keeps the old stack alive two more updates (the K6.10 finding-8 class).
|
|
31
|
+
*/
|
|
32
|
+
import * as THREE from "three";
|
|
33
|
+
import { AnalyticLightNode } from "three/webgpu";
|
|
34
|
+
import * as TSL from "three/tsl";
|
|
35
|
+
import { vdbThreeStorageStandIn } from "../grid-node.js";
|
|
36
|
+
import { getDevice } from "../device.js";
|
|
37
|
+
import { frameEmissionMaxCascades as maxCascades } from "../../tools/frame/emission.js";
|
|
38
|
+
import { vdbFrameCheckLightReset, vdbFramePrecompiling, vdbFrameRegisterLightNode, vdbFrameRenderUpdateType } from "./three-internals.js";
|
|
39
|
+
import { VDBCoreTextureBinding, vdbCoreTextureSelfTest } from "./core-textures.js";
|
|
40
|
+
import { VDBFrameStructLoaderNode, vdbFrameStructWords } from "./core-structs.js";
|
|
41
|
+
import { VDB_EMISSION_GRID, vdbEmissionProbeWgsl } from "../../core/frame/wgsl/emission.js";
|
|
42
|
+
const { code, normalWorld, positionWorld, sampler, storage, texture3D, wgslFn } = TSL;
|
|
43
|
+
/** `vec4u` words of the grid struct. */
|
|
44
|
+
const GRID_WORDS = vdbFrameStructWords(VDB_EMISSION_GRID);
|
|
45
|
+
/** The core's receiver function and the grid struct, one code node shared by every receiver (once per shader). */
|
|
46
|
+
let receiverCode = null;
|
|
47
|
+
const receiverCodeNode = () => (receiverCode ??= code(vdbEmissionProbeWgsl()));
|
|
48
|
+
/** Light nodes made so far: names each one's storage binding and WGSL functions. */
|
|
49
|
+
let names = 0;
|
|
50
|
+
/**
|
|
51
|
+
* The irradiance at a lit point from the core's probe cascades (`vdbEmissionIrradiance`: the finest cascade that holds
|
|
52
|
+
* it, blended into the next one near its sides; past the last cascade its clamped edge probes fall off with distance
|
|
53
|
+
* squared), times the light's colour × intensity.
|
|
54
|
+
*/
|
|
55
|
+
export class VDBFrameEmissionLightNode extends AnalyticLightNode {
|
|
56
|
+
static get type() {
|
|
57
|
+
return "VDBFrameEmissionLightNode";
|
|
58
|
+
}
|
|
59
|
+
/** Unique per light node: names the storage binding and the WGSL functions. */
|
|
60
|
+
k = names++;
|
|
61
|
+
#nodes = null;
|
|
62
|
+
// NOTE Replaced grid stand-ins. update() runs mid-render, so the next update() disposes them.
|
|
63
|
+
#retired = [];
|
|
64
|
+
constructor(light = null) {
|
|
65
|
+
super(light);
|
|
66
|
+
// NOTE The core update runs before the first lit mesh of each render, as shadow maps
|
|
67
|
+
const render = vdbFrameRenderUpdateType();
|
|
68
|
+
this.updateType = render;
|
|
69
|
+
this.updateBeforeType = render;
|
|
70
|
+
}
|
|
71
|
+
get emissionLight() {
|
|
72
|
+
return this.light;
|
|
73
|
+
}
|
|
74
|
+
/** The probe stack and grid bound now (null before the first receiver build); tests and harnesses. @internal */
|
|
75
|
+
get bound() {
|
|
76
|
+
const nodes = this.#nodes;
|
|
77
|
+
if (!nodes)
|
|
78
|
+
return null;
|
|
79
|
+
return { texture: this.emissionLight.coreBinding.gpu, grid: nodes.gridBuffer, placeholder: nodes.gridBuffer === nodes.placeholders.grid };
|
|
80
|
+
}
|
|
81
|
+
updateBefore(frame) {
|
|
82
|
+
const { renderer, scene, camera } = frame;
|
|
83
|
+
// NOTE No update while three precompiles materials (compileAsync), as shadow maps
|
|
84
|
+
if (vdbFramePrecompiling(renderer))
|
|
85
|
+
return undefined;
|
|
86
|
+
this.emissionLight.updateProbes(renderer, scene, camera);
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
update(frame) {
|
|
90
|
+
super.update(frame);
|
|
91
|
+
this.#retired.forEach((a) => a.dispose());
|
|
92
|
+
this.#retired.length = 0;
|
|
93
|
+
this.#bind(this.emissionLight.coreProbes);
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Points the nodes at the core's probes (null: the placeholders). A new core object gets a new stand-in as the node's
|
|
98
|
+
* `value` and bumps this node's `version`, so the receivers rebuild at their next render (see the file comment).
|
|
99
|
+
*/
|
|
100
|
+
#bind(probes) {
|
|
101
|
+
const nodes = this.#nodes;
|
|
102
|
+
if (!nodes)
|
|
103
|
+
return;
|
|
104
|
+
const p = nodes.placeholders;
|
|
105
|
+
let changed = false;
|
|
106
|
+
const binding = this.emissionLight.coreBinding;
|
|
107
|
+
if (binding.set(probes?.texture ?? p.texture)) {
|
|
108
|
+
nodes.probes.value = binding.texture;
|
|
109
|
+
changed = true;
|
|
110
|
+
}
|
|
111
|
+
const grid = probes?.grid ?? p.grid;
|
|
112
|
+
if (grid !== nodes.gridBuffer) {
|
|
113
|
+
this.#retired.push(nodes.grid.value);
|
|
114
|
+
nodes.grid.value = vdbThreeStorageStandIn(nodes.renderer, grid, `vdbEmissionGrid${this.k}`);
|
|
115
|
+
nodes.gridBuffer = grid;
|
|
116
|
+
changed = true;
|
|
117
|
+
}
|
|
118
|
+
if (changed)
|
|
119
|
+
this.needsUpdate = true;
|
|
120
|
+
}
|
|
121
|
+
#nodesOf(renderer) {
|
|
122
|
+
if (this.#nodes) {
|
|
123
|
+
if (this.#nodes.renderer === renderer)
|
|
124
|
+
return this.#nodes;
|
|
125
|
+
throw new Error("VDBFrameEmissionLight: its receivers were built by a second renderer; a light (and its scene) belongs to one renderer");
|
|
126
|
+
}
|
|
127
|
+
// NOTE The rebuild on a new core object needs three's lights cache key to follow this node's version (internal 1)
|
|
128
|
+
vdbFrameCheckLightReset();
|
|
129
|
+
const device = getDevice(renderer);
|
|
130
|
+
vdbCoreTextureSelfTest(renderer, device);
|
|
131
|
+
const placeholders = {
|
|
132
|
+
texture: device.createTexture({ label: "@pmndrs/vdb/three emission probes placeholder", size: [1, 1, 1], dimension: "3d", format: "rgba16float", usage: 0x04 /* TEXTURE_BINDING */ }),
|
|
133
|
+
// A zero grid: info.x (cascades) 0, so vdbEmissionIrradiance returns 0 without sampling
|
|
134
|
+
grid: device.createBuffer({ label: "@pmndrs/vdb/three emission grid placeholder", size: VDB_EMISSION_GRID.size, usage: 0x80 /* STORAGE */ }),
|
|
135
|
+
};
|
|
136
|
+
const light = this.emissionLight;
|
|
137
|
+
const probes = light.coreProbes;
|
|
138
|
+
light.coreBinding.set(probes?.texture ?? placeholders.texture);
|
|
139
|
+
const gridBuffer = probes?.grid ?? placeholders.grid;
|
|
140
|
+
const grid = storage(vdbThreeStorageStandIn(renderer, gridBuffer, `vdbEmissionGrid${this.k}`), "uvec4", GRID_WORDS).toReadOnly();
|
|
141
|
+
grid.setName(`vdbEmissionGrid${this.k}`);
|
|
142
|
+
const loader = new VDBFrameStructLoaderNode(grid, VDB_EMISSION_GRID, `vdbFrameEmissionGrid${this.k}`);
|
|
143
|
+
const name = `vdbFrameEmissionReceiver${this.k}`;
|
|
144
|
+
const source = `fn ${name}(probes: texture_3d<f32>, smp: sampler, world: vec3f, normal: vec3f) -> vec3f {\n return vdbEmissionIrradiance(probes, smp, ${loader.fnName}(), world, normal);\n}`;
|
|
145
|
+
const fn = wgslFn(source, [receiverCodeNode(), loader]);
|
|
146
|
+
this.#nodes = { renderer, placeholders, probes: texture3D(light.coreBinding.texture), grid, gridBuffer, fn };
|
|
147
|
+
return this.#nodes;
|
|
148
|
+
}
|
|
149
|
+
setup(builder) {
|
|
150
|
+
const b = builder;
|
|
151
|
+
const nodes = this.#nodesOf(b.renderer);
|
|
152
|
+
const irradiance = nodes.fn({ probes: nodes.probes, smp: sampler(nodes.probes), world: positionWorld, normal: normalWorld });
|
|
153
|
+
const colorNode = this.colorNode;
|
|
154
|
+
b.context.irradiance.addAssign(colorNode.mul(irradiance));
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
dispose() {
|
|
158
|
+
const nodes = this.#nodes;
|
|
159
|
+
if (nodes) {
|
|
160
|
+
this.#retired.push(nodes.grid.value);
|
|
161
|
+
const p = nodes.placeholders;
|
|
162
|
+
// NOTE A bind group of this render may still name them: destroy after the task that submits it
|
|
163
|
+
setTimeout(() => {
|
|
164
|
+
p.texture.destroy();
|
|
165
|
+
p.grid.destroy();
|
|
166
|
+
}, 0);
|
|
167
|
+
this.#nodes = null;
|
|
168
|
+
}
|
|
169
|
+
this.#retired.forEach((a) => a.dispose());
|
|
170
|
+
this.#retired.length = 0;
|
|
171
|
+
super.dispose();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/** One registration of the light node class (internal 4), checked at the first construction. */
|
|
175
|
+
let registered = false;
|
|
176
|
+
/**
|
|
177
|
+
* Light that lights lit meshes with the emission of emissive `VDBFrameVolume`s (his `FrameEmissionLight`): the core
|
|
178
|
+
* frame renderer of the scene's volumes draws the emitters and the probe cascades; this light's node reads them. Add
|
|
179
|
+
* it to the scene.
|
|
180
|
+
*/
|
|
181
|
+
export class VDBFrameEmissionLight extends THREE.Light {
|
|
182
|
+
/** Type flag. */
|
|
183
|
+
isVDBFrameEmissionLight = true;
|
|
184
|
+
/** Probes on each axis of each cascade, 2 to 32. */
|
|
185
|
+
resolution;
|
|
186
|
+
/** Size of the last cascade as a multiple of the box of all emitting volumes. */
|
|
187
|
+
range;
|
|
188
|
+
/** Probe grid cascades, 1 to 4 (1: one grid for all volumes). */
|
|
189
|
+
cascades;
|
|
190
|
+
/** Distance from the camera that the finer cascades cover. */
|
|
191
|
+
distance;
|
|
192
|
+
/** Steps of each ray in a volume (rounded, at least 1). */
|
|
193
|
+
steps;
|
|
194
|
+
/** Minimum corner of each cascade in world space (valid for the first `cascadeCount`). */
|
|
195
|
+
cascadeMin = Array.from({ length: maxCascades }, () => new THREE.Vector3());
|
|
196
|
+
/** Size of each cascade in world space (valid for the first `cascadeCount`). */
|
|
197
|
+
cascadeSize = Array.from({ length: maxCascades }, () => new THREE.Vector3(1.0, 1.0, 1.0));
|
|
198
|
+
/** Cascades in use after the last probe update. */
|
|
199
|
+
cascadeCount = 0;
|
|
200
|
+
/** Probes on each axis of each cascade after the last update. */
|
|
201
|
+
probeResolution = 2;
|
|
202
|
+
/** World centre of the probe grid after the last update. */
|
|
203
|
+
probeCenter = new THREE.Vector3();
|
|
204
|
+
/** Emissive volumes in the last update. */
|
|
205
|
+
emitterCount = 0;
|
|
206
|
+
/** Volumes drawn in the last probe update and whether the probes were drawn (not his; tests and timing). */
|
|
207
|
+
lastUpdate = { directions: 0, probes: false };
|
|
208
|
+
/** The core's probes after the last update (null: none). */
|
|
209
|
+
coreProbes = null;
|
|
210
|
+
/** @internal The stand-in of the core probe stack. */
|
|
211
|
+
coreBinding = new VDBCoreTextureBinding("3d");
|
|
212
|
+
/**
|
|
213
|
+
* Makes the light with its probe grid settings.
|
|
214
|
+
* @param props {@link VDBFrameEmissionLightProps}; all fields optional.
|
|
215
|
+
*/
|
|
216
|
+
constructor(props = {}) {
|
|
217
|
+
const { color = 0xffffff, intensity = 1.0, resolution = 16, range = 3.0, cascades = 1, distance = 512, steps = 24 } = props;
|
|
218
|
+
super(color, intensity);
|
|
219
|
+
if (!registered) {
|
|
220
|
+
vdbFrameRegisterLightNode(VDBFrameEmissionLight, VDBFrameEmissionLightNode);
|
|
221
|
+
registered = true;
|
|
222
|
+
}
|
|
223
|
+
this.type = "VDBFrameEmissionLight";
|
|
224
|
+
// K6.8b: always on, and the light casts no shadow (its node draws none). three r187's lights cache key holds the node
|
|
225
|
+
// version of a castShadow light only; the node bumps it to rebuild its receivers when the core makes new probes.
|
|
226
|
+
Object.defineProperty(this, "castShadow", { get: () => true, set: () => { }, configurable: true, enumerable: true });
|
|
227
|
+
this.resolution = resolution;
|
|
228
|
+
this.range = range;
|
|
229
|
+
this.cascades = cascades;
|
|
230
|
+
this.distance = distance;
|
|
231
|
+
this.steps = steps;
|
|
232
|
+
}
|
|
233
|
+
/** Steps of each ray, rounded and at least 1. */
|
|
234
|
+
getSteps() {
|
|
235
|
+
return Math.max(1, Math.round(this.steps));
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* The core frame of this render (the frame renderer of the scene's first visible volume) draws the emitters and the
|
|
239
|
+
* probes; this light copies the probe grid for its node. The light node calls it before the lit meshes of each render.
|
|
240
|
+
*/
|
|
241
|
+
updateProbes(renderer, scene, viewCamera) {
|
|
242
|
+
this.lastUpdate.directions = 0;
|
|
243
|
+
this.lastUpdate.probes = false;
|
|
244
|
+
let frameRenderer = null;
|
|
245
|
+
scene.traverseVisible((object) => {
|
|
246
|
+
const v = object;
|
|
247
|
+
if (!frameRenderer && v.isVDBFrameVolume)
|
|
248
|
+
frameRenderer = v.frameRenderer;
|
|
249
|
+
});
|
|
250
|
+
const fr = frameRenderer;
|
|
251
|
+
fr?.coreFrame(renderer, scene, viewCamera);
|
|
252
|
+
const probes = fr?.core?.outputs.emissionProbes ?? null;
|
|
253
|
+
this.coreProbes = probes;
|
|
254
|
+
if (!probes) {
|
|
255
|
+
this.emitterCount = 0;
|
|
256
|
+
this.cascadeCount = 0;
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const { state } = probes;
|
|
260
|
+
this.emitterCount = state.emitters;
|
|
261
|
+
this.cascadeCount = state.count;
|
|
262
|
+
this.probeResolution = state.resolution;
|
|
263
|
+
this.probeCenter.fromArray(state.center);
|
|
264
|
+
for (let i = 0; i < state.count; i++) {
|
|
265
|
+
this.cascadeMin[i].fromArray(state.min[i]);
|
|
266
|
+
this.cascadeSize[i].fromArray(state.size[i]);
|
|
267
|
+
}
|
|
268
|
+
this.lastUpdate.directions = probes.lastUpdate.directions;
|
|
269
|
+
this.lastUpdate.probes = probes.lastUpdate.probes;
|
|
270
|
+
}
|
|
271
|
+
dispose() {
|
|
272
|
+
super.dispose();
|
|
273
|
+
this.coreBinding.dispose();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
//# sourceMappingURL=emission-light.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emission-light.js","sourceR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T,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,QAAQ,CAAC;QACnC,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC;QAChC,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC,UAAU,CAAC;QACxC,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,MAA6B,CAAC,CAAC;QAChE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAE,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAwB,CAAC,CAAC;YACnE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAE,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAwB,CAAC,CAAC;QACvE,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC;QAC1D,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;IACpD,CAAC;IAEQ,OAAO;QACd,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACF","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/FrameEmissionLight.js L1–287 (FrameEmissionLightBase: props, probe cascades);\n// src/three-openvdb/frame/webgpu/FrameEmissionLight.js L59–658 (FrameEmissionLightNode: the probe lookup with the\n// cascade blend and the falloff past the last cascade; FrameEmissionLight: props, the node registration).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; K6.8: the emitters and probes are the core frame renderer's (its emission kernels, a stacked 3D\n// texture read with hardware trilinear); this light carries the settings and lights meshes; K6.8b: the lookup is the\n// core's own WGSL (`vdbEmissionIrradiance` of `vdbEmissionProbeWgsl()`) through a `wgslFn`, the probe grid read from the\n// core's buffer through a storage stand-in, instead of a TSL port; every three r187 internal goes through\n// `three-internals.ts` or the stand-in self-tests (VDB_ENGINE_MISMATCH on another three). Divergences: DIVERGES.md (K3.6,\n// K6.5, K6.8b rows).\n\n/**\n * K3.6 / K6.5: light from the emissive grids of every visible `VDBFrameVolume` (his `FrameEmissionLight`). Add one to\n * the scene; three's lit node materials (`MeshStandardMaterial`, `MeshLambertMaterial`, …) receive it as irradiance,\n * like a light probe. The core frame renderer of the scene's volumes draws the emitters and L1 irradiance probes (up to\n * 4 cascades of ≤ 32³) when a volume or the cascades changed; a lit pixel reads 6 texels (12 near a cascade side).\n *\n * const light = new VDBFrameEmissionLight({ intensity: 25, resolution: 32 });\n * scene.add(light); // volumes need an emission channel; colour: VDBFrameVolume `emissionColor`\n *\n * K6.8b: a lit pixel runs the core's `vdbEmissionIrradiance(probes, smp, grid, world, normal)` (`vdbEmissionProbeWgsl()`,\n * twin `vdbFrameEmissionLookup` + `vdbFrameEmissionIrradiance`) through a `wgslFn`: `probes` is the core's probe stack\n * (`outputs.emissionProbes.texture`, a 3D texture stand-in) and `grid` its `VdbEmissionGrid` buffer\n * (`outputs.emissionProbes.grid`, bound through a storage stand-in and unpacked from `array<vec4u>`; the core rewrites it\n * each update). The texture and storage nodes are made once; their `value` follows the core (placeholders while it has no\n * probes: a 1³ texture and a zero grid, which lights nothing). three r187 re-reads a plain material's texture and storage\n * bindings only on a full refresh, so a new core object (a new probe resolution, a released stack, another frame\n * renderer) also rebuilds the receivers: the light keeps `castShadow` on (it casts no shadow) and its node bumps\n * `version`, which three's lights cache key holds for a `castShadow` light. They rebuild at their next render; the core\n * keeps the old stack alive two more updates (the K6.10 finding-8 class).\n */\n\nimport * as THREE from \"three\";\nimport { AnalyticLightNode, type StorageBufferAttribute } from \"three/webgpu\";\nimport * as TSL from \"three/tsl\";\nimport { vdbThreeStorageStandIn, type VDBTslNode } from \"../grid-node.js\";\nimport { getDevice } from \"../device.js\";\nimport { frameEmissionMaxCascades as maxCascades } from \"../../tools/frame/emission.js\";\nimport { vdbFrameCheckLightReset, vdbFramePrecompiling, vdbFrameRegisterLightNode, vdbFrameRenderUpdateType } from \"./three-internals.js\";\nimport { VDBCoreTextureBinding, vdbCoreTextureSelfTest } from \"./core-textures.js\";\nimport { VDBFrameStructLoaderNode, vdbFrameStructWords, type VDBFrameStorageNode } from \"./core-structs.js\";\nimport { VDB_EMISSION_GRID, vdbEmissionProbeWgsl } from \"../../core/frame/wgsl/emission.js\";\nimport type { VDBFrameEmissionProbes } from \"../../core/frame/types.js\";\nimport type { VDBFrameRenderer } from \"./renderer.js\";\nimport type { VDBFrameVolume } from \"./volume.js\";\n\nconst { code, normalWorld, positionWorld, sampler, storage, texture3D, wgslFn } = TSL as unknown as Record<string, VDBTslNode>;\n\ntype N = VDBTslNode;\n\n/** `vec4u` words of the grid struct. */\nconst GRID_WORDS = vdbFrameStructWords(VDB_EMISSION_GRID);\n\n/** The core's receiver function and the grid struct, one code node shared by every receiver (once per shader). */\nlet receiverCode: N | null = null;\nconst receiverCodeNode = (): N => (receiverCode ??= code(vdbEmissionProbeWgsl()));\n\n/** Light nodes made so far: names each one's storage binding and WGSL functions. */\nlet names = 0;\n\n/** What the receivers bind while the core has no probes: a 1³ stack and a zero grid (`info.x` 0: no light, no sample). */\ninterface Placeholders {\n texture: GPUTexture;\n grid: GPUBuffer;\n}\n\n/** A light node's three nodes; made at its first receiver build, their values follow the core. */\ninterface ReceiverNodes {\n renderer: object;\n placeholders: Placeholders;\n probes: N;\n grid: VDBFrameStorageNode;\n /** The grid buffer bound now (the core's or the placeholder). */\n gridBuffer: GPUBuffer;\n fn: (inputs: Record<string, N>) => N;\n}\n\n/**\n * The irradiance at a lit point from the core's probe cascades (`vdbEmissionIrradiance`: the finest cascade that holds\n * it, blended into the next one near its sides; past the last cascade its clamped edge probes fall off with distance\n * squared), times the light's colour × intensity.\n */\nexport class VDBFrameEmissionLightNode extends AnalyticLightNode<THREE.Light> {\n static get type(): string {\n return \"VDBFrameEmissionLightNode\";\n }\n\n /** Unique per light node: names the storage binding and the WGSL functions. */\n readonly k = names++;\n #nodes: ReceiverNodes | null = null;\n // NOTE Replaced grid stand-ins. update() runs mid-render, so the next update() disposes them.\n #retired: StorageBufferAttribute[] = [];\n\n constructor(light: VDBFrameEmissionLight | null = null) {\n super(light as never);\n // NOTE The core update runs before the first lit mesh of each render, as shadow maps\n const render = vdbFrameRenderUpdateType();\n (this as unknown as { updateType: string; updateBeforeType: string }).updateType = render;\n (this as unknown as { updateType: string; updateBeforeType: string }).updateBeforeType = render;\n }\n\n private get emissionLight(): VDBFrameEmissionLight {\n return (this as unknown as { light: VDBFrameEmissionLight }).light;\n }\n\n /** The probe stack and grid bound now (null before the first receiver build); tests and harnesses. @internal */\n get bound(): { texture: GPUTexture | null; grid: GPUBuffer; placeholder: boolean } | null {\n const nodes = this.#nodes;\n if (!nodes) return null;\n return { texture: this.emissionLight.coreBinding.gpu, grid: nodes.gridBuffer, placeholder: nodes.gridBuffer === nodes.placeholders.grid };\n }\n\n override updateBefore(frame: never): boolean | undefined {\n const { renderer, scene, camera } = frame as { renderer: object; scene: THREE.Scene; camera: THREE.Camera };\n // NOTE No update while three precompiles materials (compileAsync), as shadow maps\n if (vdbFramePrecompiling(renderer)) return undefined;\n this.emissionLight.updateProbes(renderer, scene, camera);\n return undefined;\n }\n\n override update(frame: never): boolean | undefined {\n super.update(frame);\n this.#retired.forEach((a) => a.dispose());\n this.#retired.length = 0;\n this.#bind(this.emissionLight.coreProbes);\n return undefined;\n }\n\n /**\n * Points the nodes at the core's probes (null: the placeholders). A new core object gets a new stand-in as the node's\n * `value` and bumps this node's `version`, so the receivers rebuild at their next render (see the file comment).\n */\n #bind(probes: VDBFrameEmissionProbes | null): void {\n const nodes = this.#nodes;\n if (!nodes) return;\n const p = nodes.placeholders;\n let changed = false;\n const binding = this.emissionLight.coreBinding;\n if (binding.set(probes?.texture ?? p.texture)) {\n nodes.probes.value = binding.texture;\n changed = true;\n }\n const grid = probes?.grid ?? p.grid;\n if (grid !== nodes.gridBuffer) {\n this.#retired.push(nodes.grid.value as StorageBufferAttribute);\n nodes.grid.value = vdbThreeStorageStandIn(nodes.renderer, grid, `vdbEmissionGrid${this.k}`);\n nodes.gridBuffer = grid;\n changed = true;\n }\n if (changed) (this as unknown as { needsUpdate: boolean }).needsUpdate = true;\n }\n\n #nodesOf(renderer: object): ReceiverNodes {\n if (this.#nodes) {\n if (this.#nodes.renderer === renderer) return this.#nodes;\n throw new Error(\"VDBFrameEmissionLight: its receivers were built by a second renderer; a light (and its scene) belongs to one renderer\");\n }\n // NOTE The rebuild on a new core object needs three's lights cache key to follow this node's version (internal 1)\n vdbFrameCheckLightReset();\n const device = getDevice(renderer as never);\n vdbCoreTextureSelfTest(renderer as never, device);\n const placeholders: Placeholders = {\n texture: device.createTexture({ label: \"@pmndrs/vdb/three emission probes placeholder\", size: [1, 1, 1], dimension: \"3d\", format: \"rgba16float\", usage: 0x04 /* TEXTURE_BINDING */ }),\n // A zero grid: info.x (cascades) 0, so vdbEmissionIrradiance returns 0 without sampling\n grid: device.createBuffer({ label: \"@pmndrs/vdb/three emission grid placeholder\", size: VDB_EMISSION_GRID.size, usage: 0x80 /* STORAGE */ }),\n };\n const light = this.emissionLight;\n const probes = light.coreProbes;\n light.coreBinding.set(probes?.texture ?? placeholders.texture);\n const gridBuffer = probes?.grid ?? placeholders.grid;\n const grid = storage(vdbThreeStorageStandIn(renderer, gridBuffer, `vdbEmissionGrid${this.k}`), \"uvec4\", GRID_WORDS).toReadOnly() as VDBFrameStorageNode;\n grid.setName(`vdbEmissionGrid${this.k}`);\n const loader = new VDBFrameStructLoaderNode(grid, VDB_EMISSION_GRID, `vdbFrameEmissionGrid${this.k}`);\n const name = `vdbFrameEmissionReceiver${this.k}`;\n const source = `fn ${name}(probes: texture_3d<f32>, smp: sampler, world: vec3f, normal: vec3f) -> vec3f {\\n return vdbEmissionIrradiance(probes, smp, ${loader.fnName}(), world, normal);\\n}`;\n const fn = wgslFn(source, [receiverCodeNode(), loader]) as (inputs: Record<string, N>) => N;\n this.#nodes = { renderer, placeholders, probes: texture3D(light.coreBinding.texture), grid, gridBuffer, fn };\n return this.#nodes;\n }\n\n override setup(builder: never): null {\n const b = builder as unknown as { renderer: object; context: { irradiance: N } };\n const nodes = this.#nodesOf(b.renderer);\n const irradiance = nodes.fn({ probes: nodes.probes, smp: sampler(nodes.probes), world: positionWorld, normal: normalWorld });\n const colorNode = (this as unknown as { colorNode: N }).colorNode;\n b.context.irradiance.addAssign(colorNode.mul(irradiance));\n return null;\n }\n\n override dispose(): void {\n const nodes = this.#nodes;\n if (nodes) {\n this.#retired.push(nodes.grid.value as StorageBufferAttribute);\n const p = nodes.placeholders;\n // NOTE A bind group of this render may still name them: destroy after the task that submits it\n setTimeout(() => {\n p.texture.destroy();\n p.grid.destroy();\n }, 0);\n this.#nodes = null;\n }\n this.#retired.forEach((a) => a.dispose());\n this.#retired.length = 0;\n super.dispose();\n }\n}\n\n/** Props of {@link VDBFrameEmissionLight} (his `FrameEmissionLight` props; same names and defaults). */\nexport interface VDBFrameEmissionLightProps {\n /** Light colour (default white). */\n color?: THREE.ColorRepresentation;\n /** Light intensity, a multiplier of the volumes' emitted light (default 1). */\n intensity?: number;\n /** Probes on each axis of each cascade, 2–32 (default 16). */\n resolution?: number;\n /** Size of the last cascade as a multiple of the box of all emitting volumes; past it light falls off with distance² (default 3). */\n range?: number;\n /** 1: one grid for all volumes. Up to 4: finer grids around the camera (default 1). */\n cascades?: number;\n /** The finer cascades cover this distance from the camera (default 512). */\n distance?: number;\n /** Steps of each ray in a volume (default 24). */\n steps?: number;\n}\n\n/** One registration of the light node class (internal 4), checked at the first construction. */\nlet registered = false;\n\n/**\n * Light that lights lit meshes with the emission of emissive `VDBFrameVolume`s (his `FrameEmissionLight`): the core\n * frame renderer of the scene's volumes draws the emitters and the probe cascades; this light's node reads them. Add\n * it to the scene.\n */\nexport class VDBFrameEmissionLight extends THREE.Light {\n /** Type flag. */\n readonly isVDBFrameEmissionLight = true as const;\n\n /** Probes on each axis of each cascade, 2 to 32. */\n resolution: number;\n /** Size of the last cascade as a multiple of the box of all emitting volumes. */\n range: number;\n /** Probe grid cascades, 1 to 4 (1: one grid for all volumes). */\n cascades: number;\n /** Distance from the camera that the finer cascades cover. */\n distance: number;\n /** Steps of each ray in a volume (rounded, at least 1). */\n steps: number;\n\n /** Minimum corner of each cascade in world space (valid for the first `cascadeCount`). */\n readonly cascadeMin = Array.from({ length: maxCascades }, () => new THREE.Vector3());\n /** Size of each cascade in world space (valid for the first `cascadeCount`). */\n readonly cascadeSize = Array.from({ length: maxCascades }, () => new THREE.Vector3(1.0, 1.0, 1.0));\n /** Cascades in use after the last probe update. */\n cascadeCount = 0;\n /** Probes on each axis of each cascade after the last update. */\n probeResolution = 2;\n /** World centre of the probe grid after the last update. */\n readonly probeCenter = new THREE.Vector3();\n /** Emissive volumes in the last update. */\n emitterCount = 0;\n /** Volumes drawn in the last probe update and whether the probes were drawn (not his; tests and timing). */\n readonly lastUpdate = { directions: 0, probes: false };\n /** The core's probes after the last update (null: none). */\n coreProbes: VDBFrameEmissionProbes | null = null;\n /** @internal The stand-in of the core probe stack. */\n readonly coreBinding = new VDBCoreTextureBinding(\"3d\");\n\n /**\n * Makes the light with its probe grid settings.\n * @param props {@link VDBFrameEmissionLightProps}; all fields optional.\n */\n constructor(props: VDBFrameEmissionLightProps = {}) {\n const { color = 0xffffff, intensity = 1.0, resolution = 16, range = 3.0, cascades = 1, distance = 512, steps = 24 } = props;\n super(color, intensity);\n if (!registered) {\n vdbFrameRegisterLightNode(VDBFrameEmissionLight as unknown as typeof THREE.Light, VDBFrameEmissionLightNode);\n registered = true;\n }\n (this as { type: string }).type = \"VDBFrameEmissionLight\";\n // K6.8b: always on, and the light casts no shadow (its node draws none). three r187's lights cache key holds the node\n // version of a castShadow light only; the node bumps it to rebuild its receivers when the core makes new probes.\n Object.defineProperty(this, \"castShadow\", { get: () => true, set: () => {}, configurable: true, enumerable: true });\n this.resolution = resolution;\n this.range = range;\n this.cascades = cascades;\n this.distance = distance;\n this.steps = steps;\n }\n\n /** Steps of each ray, rounded and at least 1. */\n getSteps(): number {\n return Math.max(1, Math.round(this.steps));\n }\n\n /**\n * The core frame of this render (the frame renderer of the scene's first visible volume) draws the emitters and the\n * probes; this light copies the probe grid for its node. The light node calls it before the lit meshes of each render.\n */\n updateProbes(renderer: object, scene: THREE.Object3D, viewCamera: THREE.Camera): void {\n this.lastUpdate.directions = 0;\n this.lastUpdate.probes = false;\n let frameRenderer: VDBFrameRenderer | null = null;\n scene.traverseVisible((object) => {\n const v = object as VDBFrameVolume;\n if (!frameRenderer && v.isVDBFrameVolume) frameRenderer = v.frameRenderer;\n });\n const fr = frameRenderer as VDBFrameRenderer | null;\n fr?.coreFrame(renderer as never, scene as never, viewCamera);\n const probes = fr?.core?.outputs.emissionProbes ?? null;\n this.coreProbes = probes;\n if (!probes) {\n this.emitterCount = 0;\n this.cascadeCount = 0;\n return;\n }\n const { state } = probes;\n this.emitterCount = state.emitters;\n this.cascadeCount = state.count;\n this.probeResolution = state.resolution;\n this.probeCenter.fromArray(state.center as unknown as number[]);\n for (let i = 0; i < state.count; i++) {\n this.cascadeMin[i]!.fromArray(state.min[i] as unknown as number[]);\n this.cascadeSize[i]!.fromArray(state.size[i] as unknown as number[]);\n }\n this.lastUpdate.directions = probes.lastUpdate.directions;\n this.lastUpdate.probes = probes.lastUpdate.probes;\n }\n\n override dispose(): void {\n super.dispose();\n this.coreBinding.dispose();\n }\n}\n"]}
|