@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/frame/view.js
DELETED
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
-
// src/three-openvdb/frame/core/frameView.js (all, 357 lines).
|
|
3
|
-
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
4
|
-
// Changes: TypeScript; the collector visits `isVDBFrameVolume` objects and has no shadow-grid
|
|
5
|
-
// casters' mip query beyond `hasMipmaps`. Divergences: DIVERGES.md (K3.1 rows).
|
|
6
|
-
/**
|
|
7
|
-
* View code of the froxel renderer, the same for all backends (R1 bucket A: frustum clip of the
|
|
8
|
-
* volume boxes, log slice ranges, froxel rectangle and area, distance fade radius) plus the scene
|
|
9
|
-
* traversal (`FrameVolumeCollector`, bucket B). It makes no objects per frame. The engine-free part
|
|
10
|
-
* moves to `core` in K3.8.
|
|
11
|
-
*/
|
|
12
|
-
import { Box3, Frustum, Matrix4, Vector3, Vector4 } from "three";
|
|
13
|
-
const unitBox = new Box3(new Vector3(-0.5, -0.5, -0.5), new Vector3(0.5, 0.5, 0.5));
|
|
14
|
-
const frustum = new Frustum();
|
|
15
|
-
const projectionScreenMatrix = new Matrix4();
|
|
16
|
-
const clipMatrix = new Matrix4();
|
|
17
|
-
const corner = new Vector4();
|
|
18
|
-
const viewFrustum = new Frustum();
|
|
19
|
-
const boxCorners = Array.from({ length: 8 }, () => new Vector3());
|
|
20
|
-
const clipPolygons = [Array.from({ length: 12 }, () => new Vector3()), Array.from({ length: 12 }, () => new Vector3())];
|
|
21
|
-
const clipDepths = { near: 0.0, far: 0.0 };
|
|
22
|
-
const frustumCorners = Array.from({ length: 8 }, () => new Vector3());
|
|
23
|
-
const localCorner = new Vector3();
|
|
24
|
-
const crossA = new Vector3();
|
|
25
|
-
const crossB = new Vector3();
|
|
26
|
-
const crossC = new Vector3();
|
|
27
|
-
// NOTE Point where three planes meet (normal . p + constant = 0 for each). Writes target.
|
|
28
|
-
const intersectPlanes = (a, b, c, target) => {
|
|
29
|
-
crossA.crossVectors(b.normal, c.normal);
|
|
30
|
-
crossB.crossVectors(c.normal, a.normal);
|
|
31
|
-
crossC.crossVectors(a.normal, b.normal);
|
|
32
|
-
return target
|
|
33
|
-
.copy(crossA)
|
|
34
|
-
.multiplyScalar(-a.constant)
|
|
35
|
-
.addScaledVector(crossB, -b.constant)
|
|
36
|
-
.addScaledVector(crossC, -c.constant)
|
|
37
|
-
.divideScalar(a.normal.dot(crossA));
|
|
38
|
-
};
|
|
39
|
-
// NOTE Corners of the view space frustum. The planes of Frustum are in pairs: x (0, 1), y (2, 3) and z (4, 5).
|
|
40
|
-
const setFrustumCorners = (planes) => {
|
|
41
|
-
for (let i = 0; i < 8; i++) {
|
|
42
|
-
intersectPlanes(planes[i & 1], planes[2 + ((i >> 1) & 1)], planes[4 + ((i >> 2) & 1)], frustumCorners[i]);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
// NOTE Corners of each face of the unit box, in order around the face (corner bits: 1 x, 2 y, 4 z)
|
|
46
|
-
const boxFaces = [
|
|
47
|
-
[0, 2, 6, 4],
|
|
48
|
-
[1, 3, 7, 5],
|
|
49
|
-
[0, 1, 5, 4],
|
|
50
|
-
[2, 3, 7, 6],
|
|
51
|
-
[0, 1, 3, 2],
|
|
52
|
-
[4, 5, 7, 6],
|
|
53
|
-
];
|
|
54
|
-
const setBoxCorners = (localToView) => {
|
|
55
|
-
for (let i = 0; i < 8; i++) {
|
|
56
|
-
boxCorners[i].set(i & 1 ? 0.5 : -0.5, i & 2 ? 0.5 : -0.5, i & 4 ? 0.5 : -0.5).applyMatrix4(localToView);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
// NOTE View depth range of the part of the box inside the view space frustum. The faces of the box are clipped to the
|
|
60
|
-
// planes, so a box that reaches behind the camera or past the side of the view does not widen the range. The frustum
|
|
61
|
-
// corners inside the box are the other corners of that part: with the camera in the box the range starts at the near
|
|
62
|
-
// plane. Writes clipDepths and returns false when no part of the box is in the frustum.
|
|
63
|
-
const getClippedDepths = (clipFrustum, viewToLocal) => {
|
|
64
|
-
let near = Infinity;
|
|
65
|
-
let far = -Infinity;
|
|
66
|
-
for (let i = 0; i < 8; i++) {
|
|
67
|
-
localCorner.copy(frustumCorners[i]).applyMatrix4(viewToLocal);
|
|
68
|
-
if (unitBox.containsPoint(localCorner)) {
|
|
69
|
-
near = Math.min(near, -frustumCorners[i].z);
|
|
70
|
-
far = Math.max(far, -frustumCorners[i].z);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
for (let f = 0; f < 6; f++) {
|
|
74
|
-
let input = clipPolygons[0];
|
|
75
|
-
let output = clipPolygons[1];
|
|
76
|
-
let count = 4;
|
|
77
|
-
for (let i = 0; i < 4; i++) {
|
|
78
|
-
input[i].copy(boxCorners[boxFaces[f][i]]);
|
|
79
|
-
}
|
|
80
|
-
for (let p = 0; p < 6 && count > 0; p++) {
|
|
81
|
-
const plane = clipFrustum.planes[p];
|
|
82
|
-
let outputCount = 0;
|
|
83
|
-
for (let i = 0; i < count; i++) {
|
|
84
|
-
const a = input[i];
|
|
85
|
-
const b = input[(i + 1) % count];
|
|
86
|
-
const da = plane.distanceToPoint(a);
|
|
87
|
-
const db = plane.distanceToPoint(b);
|
|
88
|
-
if (da >= 0.0) {
|
|
89
|
-
output[outputCount++].copy(a);
|
|
90
|
-
}
|
|
91
|
-
if (da >= 0.0 !== db >= 0.0) {
|
|
92
|
-
output[outputCount++].lerpVectors(a, b, da / (da - db));
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
count = outputCount;
|
|
96
|
-
[input, output] = [output, input];
|
|
97
|
-
}
|
|
98
|
-
for (let i = 0; i < count; i++) {
|
|
99
|
-
near = Math.min(near, -input[i].z);
|
|
100
|
-
far = Math.max(far, -input[i].z);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
clipDepths.near = near;
|
|
104
|
-
clipDepths.far = far;
|
|
105
|
-
return near <= far;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* Finds the ready volumes of the visible frame volumes (his `FrameVolumeCollector`). `volumes`: in
|
|
109
|
-
* the view. `casters`: all, when `useGrid` (the 'frame' lighting shadow grid, K3.3). Entries and
|
|
110
|
-
* arrays are reused by the next `collect()`.
|
|
111
|
-
*/
|
|
112
|
-
export class FrameVolumeCollector {
|
|
113
|
-
volumes = [];
|
|
114
|
-
casters = [];
|
|
115
|
-
// NOTE View depth range of the volumes in the view
|
|
116
|
-
near = 0.0;
|
|
117
|
-
far = 0.0;
|
|
118
|
-
entries = [];
|
|
119
|
-
usedEntries = 0;
|
|
120
|
-
camera = null;
|
|
121
|
-
useGrid = false;
|
|
122
|
-
prepareVolume = null;
|
|
123
|
-
visitObject;
|
|
124
|
-
constructor() {
|
|
125
|
-
this.visitObject = (object) => {
|
|
126
|
-
const frameVolume = object;
|
|
127
|
-
if (!frameVolume.isVDBFrameVolume || !frameVolume.proxy.layers.test(this.camera.layers)) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
// G16a: a source that follows its grid's image may move the volume's box; re-read it before placing the box
|
|
131
|
-
frameVolume.syncSource?.();
|
|
132
|
-
const { volumes } = frameVolume;
|
|
133
|
-
for (let i = 0; i < volumes.length; i++) {
|
|
134
|
-
this.addVolume(frameVolume, volumes[i]);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
getEntry(frameVolume, volume) {
|
|
139
|
-
if (this.usedEntries === this.entries.length) {
|
|
140
|
-
this.entries.push({ frameVolume, volume });
|
|
141
|
-
}
|
|
142
|
-
const entry = this.entries[this.usedEntries++];
|
|
143
|
-
entry.frameVolume = frameVolume;
|
|
144
|
-
entry.volume = volume;
|
|
145
|
-
return entry;
|
|
146
|
-
}
|
|
147
|
-
addVolume(frameVolume, volume) {
|
|
148
|
-
if (!volume.ready) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
const camera = this.camera;
|
|
152
|
-
this.prepareVolume?.(frameVolume, volume);
|
|
153
|
-
volume.matrixWorld.multiplyMatrices(frameVolume.matrixWorld, volume.matrix);
|
|
154
|
-
volume.worldToLocal.copy(volume.matrixWorld).invert();
|
|
155
|
-
volume.worldBox.copy(unitBox).applyMatrix4(volume.matrixWorld);
|
|
156
|
-
const entry = this.getEntry(frameVolume, volume);
|
|
157
|
-
// NOTE Volumes out of the view can still cast shadows on visible volumes
|
|
158
|
-
if (this.useGrid) {
|
|
159
|
-
this.casters.push(entry);
|
|
160
|
-
}
|
|
161
|
-
if (!frustum.intersectsBox(volume.worldBox)) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
volume.localToView.multiplyMatrices(camera.matrixWorldInverse, volume.matrixWorld);
|
|
165
|
-
volume.viewToLocal.copy(volume.localToView).invert();
|
|
166
|
-
setBoxCorners(volume.localToView);
|
|
167
|
-
if (!getClippedDepths(viewFrustum, volume.viewToLocal)) {
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
volume.viewNear = clipDepths.near;
|
|
171
|
-
volume.viewFar = clipDepths.far;
|
|
172
|
-
this.near = Math.min(this.near, volume.viewNear);
|
|
173
|
-
this.far = Math.max(this.far, volume.viewFar);
|
|
174
|
-
this.volumes.push(entry);
|
|
175
|
-
}
|
|
176
|
-
/** settings: near and far of the renderer settings. Returns this; `volumes` is empty when none is in view. */
|
|
177
|
-
collect(scene, camera, settings, useGrid, prepareVolume = null) {
|
|
178
|
-
this.volumes.length = 0;
|
|
179
|
-
this.casters.length = 0;
|
|
180
|
-
this.usedEntries = 0;
|
|
181
|
-
this.near = Infinity;
|
|
182
|
-
this.far = 0.0;
|
|
183
|
-
this.camera = camera;
|
|
184
|
-
this.useGrid = useGrid;
|
|
185
|
-
this.prepareVolume = prepareVolume;
|
|
186
|
-
projectionScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);
|
|
187
|
-
frustum.setFromProjectionMatrix(projectionScreenMatrix);
|
|
188
|
-
viewFrustum.setFromProjectionMatrix(camera.projectionMatrix, camera.coordinateSystem, camera.reversedDepth);
|
|
189
|
-
setFrustumCorners(viewFrustum.planes);
|
|
190
|
-
scene.traverseVisible(this.visitObject);
|
|
191
|
-
// NOTE Fit the slices to the visible volumes. Then no slices are used for empty space.
|
|
192
|
-
this.near = Math.max(this.near, settings.near, camera.near);
|
|
193
|
-
this.far = Math.min(this.far, settings.far, camera.far);
|
|
194
|
-
if (this.far <= this.near) {
|
|
195
|
-
this.volumes.length = 0;
|
|
196
|
-
}
|
|
197
|
-
this.far = Math.max(this.far, this.near * 1.0001);
|
|
198
|
-
this.camera = null;
|
|
199
|
-
this.prepareVolume = null;
|
|
200
|
-
return this;
|
|
201
|
-
}
|
|
202
|
-
/** True when a volume in the view or a caster uses mipmaps. */
|
|
203
|
-
hasMipmaps() {
|
|
204
|
-
return hasMipmaps(this.volumes) || hasMipmaps(this.casters);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
const hasMipmaps = (items) => {
|
|
208
|
-
for (let i = 0; i < items.length; i++) {
|
|
209
|
-
if (items[i].frameVolume.mipmaps) {
|
|
210
|
-
return true;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
return false;
|
|
214
|
-
};
|
|
215
|
-
/** Uniform value of settings.fadeRadius. 0 turns the distance fade off. */
|
|
216
|
-
export const getFrameFadeRadius = (settings) => Number.isFinite(settings.fadeRadius) && settings.fadeRadius > 0.0 ? settings.fadeRadius : 0.0;
|
|
217
|
-
/** Fractional slice of a view depth. range: froxelRange (near, far). Slices are logarithmic. */
|
|
218
|
-
export const getFroxelSlice = (viewDepth, range, depth) => (depth * Math.log(Math.max(viewDepth, range.x) / range.x)) / Math.log(range.y / range.x);
|
|
219
|
-
/** First slice and slice count of a volume. Writes target ({ first, count }) and returns it. */
|
|
220
|
-
export const getFroxelSliceRange = (volume, range, depth, target) => {
|
|
221
|
-
const first = Math.max(0, Math.floor(getFroxelSlice(volume.viewNear, range, depth)));
|
|
222
|
-
const last = Math.min(depth - 1, Math.ceil(getFroxelSlice(volume.viewFar, range, depth)));
|
|
223
|
-
target.first = first;
|
|
224
|
-
target.count = last - first + 1;
|
|
225
|
-
return target;
|
|
226
|
-
};
|
|
227
|
-
/**
|
|
228
|
-
* Screen rectangle of the volume in froxel cells (x0, y0, x1, y1), with one cell of padding for the
|
|
229
|
-
* linear filter. Writes target. Returns false when the volume covers no cell.
|
|
230
|
-
*/
|
|
231
|
-
export const getFroxelRect = (volume, camera, width, height, target) => {
|
|
232
|
-
let minX = Infinity;
|
|
233
|
-
let minY = Infinity;
|
|
234
|
-
let maxX = -Infinity;
|
|
235
|
-
let maxY = -Infinity;
|
|
236
|
-
clipMatrix.multiplyMatrices(camera.projectionMatrix, volume.localToView);
|
|
237
|
-
for (let i = 0; i < 8; i++) {
|
|
238
|
-
corner.set(i & 1 ? 0.5 : -0.5, i & 2 ? 0.5 : -0.5, i & 4 ? 0.5 : -0.5, 1.0).applyMatrix4(clipMatrix);
|
|
239
|
-
// NOTE A corner behind the camera: the volume can cover all of the screen
|
|
240
|
-
if (corner.w <= 1e-6) {
|
|
241
|
-
target.set(0.0, 0.0, width, height);
|
|
242
|
-
return true;
|
|
243
|
-
}
|
|
244
|
-
minX = Math.min(minX, corner.x / corner.w);
|
|
245
|
-
minY = Math.min(minY, corner.y / corner.w);
|
|
246
|
-
maxX = Math.max(maxX, corner.x / corner.w);
|
|
247
|
-
maxY = Math.max(maxY, corner.y / corner.w);
|
|
248
|
-
}
|
|
249
|
-
const x0 = Math.max(0, Math.floor((minX * 0.5 + 0.5) * width) - 1);
|
|
250
|
-
const y0 = Math.max(0, Math.floor((minY * 0.5 + 0.5) * height) - 1);
|
|
251
|
-
const x1 = Math.min(width, Math.ceil((maxX * 0.5 + 0.5) * width) + 1);
|
|
252
|
-
const y1 = Math.min(height, Math.ceil((maxY * 0.5 + 0.5) * height) + 1);
|
|
253
|
-
if (x1 <= x0 || y1 <= y0) {
|
|
254
|
-
return false;
|
|
255
|
-
}
|
|
256
|
-
target.set(x0, y0, x1, y1);
|
|
257
|
-
return true;
|
|
258
|
-
};
|
|
259
|
-
const volumeRect = new Vector4();
|
|
260
|
-
const volumeSlices = { first: 0, count: 0 };
|
|
261
|
-
/**
|
|
262
|
-
* Froxel area of all volumes: the union of their rectangles and slices, one cell and one slice
|
|
263
|
-
* larger on each side. Writes area; count is 0 when no volume covers a cell.
|
|
264
|
-
*/
|
|
265
|
-
export const getFroxelArea = (volumes, camera, width, height, range, depth, area) => {
|
|
266
|
-
let x0 = Infinity;
|
|
267
|
-
let y0 = Infinity;
|
|
268
|
-
let x1 = -Infinity;
|
|
269
|
-
let y1 = -Infinity;
|
|
270
|
-
let first = Infinity;
|
|
271
|
-
let last = -Infinity;
|
|
272
|
-
for (let i = 0; i < volumes.length; i++) {
|
|
273
|
-
const { volume } = volumes[i];
|
|
274
|
-
if (!getFroxelRect(volume, camera, width, height, volumeRect)) {
|
|
275
|
-
continue;
|
|
276
|
-
}
|
|
277
|
-
getFroxelSliceRange(volume, range, depth, volumeSlices);
|
|
278
|
-
x0 = Math.min(x0, volumeRect.x);
|
|
279
|
-
y0 = Math.min(y0, volumeRect.y);
|
|
280
|
-
x1 = Math.max(x1, volumeRect.z);
|
|
281
|
-
y1 = Math.max(y1, volumeRect.w);
|
|
282
|
-
first = Math.min(first, volumeSlices.first);
|
|
283
|
-
last = Math.max(last, volumeSlices.first + volumeSlices.count - 1);
|
|
284
|
-
}
|
|
285
|
-
if (first > last) {
|
|
286
|
-
area.rect.set(0.0, 0.0, 0.0, 0.0);
|
|
287
|
-
area.first = 0;
|
|
288
|
-
area.count = 0;
|
|
289
|
-
return area;
|
|
290
|
-
}
|
|
291
|
-
area.rect.set(Math.max(0, x0 - 1), Math.max(0, y0 - 1), Math.min(width, x1 + 1), Math.min(height, y1 + 1));
|
|
292
|
-
area.first = Math.max(0, first - 1);
|
|
293
|
-
area.count = Math.min(depth - 1, last + 1) - area.first + 1;
|
|
294
|
-
return area;
|
|
295
|
-
};
|
|
296
|
-
//# sourceMappingURL=view.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../../src/three/frame/view.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,gEAAgE;AAChE,4GAA4G;AAC5G,8FAA8F;AAC9F,gFAAgF;AAEhF;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAA4D,MAAM,OAAO,CAAC;AA8B3H,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AACpF,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAC9B,MAAM,sBAAsB,GAAG,IAAI,OAAO,EAAE,CAAC;AAC7C,MAAM,UAAU,GAAG,IAAI,OAAO,EAAE,CAAC;AACjC,MAAM,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;AAC7B,MAAM,WAAW,GAAG,IAAI,OAAO,EAAE,CAAC;AAClC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC;AAClE,MAAM,YAAY,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC,CAAC;AACxH,MAAM,UAAU,GAAG,EAAE,IAAI,EAAE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AC;QAC5C,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,IAAI,KAAK,GAAG,IAAI,EAAE,CAAC;QACjB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QAEf,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3G,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IACpC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IAE5D,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/core/frameView.js (all, 357 lines).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; the collector visits `isVDBFrameVolume` objects and has no shadow-grid\n// casters' mip query beyond `hasMipmaps`. Divergences: DIVERGES.md (K3.1 rows).\n\n/**\n * View code of the froxel renderer, the same for all backends (R1 bucket A: frustum clip of the\n * volume boxes, log slice ranges, froxel rectangle and area, distance fade radius) plus the scene\n * traversal (`FrameVolumeCollector`, bucket B). It makes no objects per frame. The engine-free part\n * moves to `core` in K3.8.\n */\n\nimport { Box3, Frustum, Matrix4, Vector3, Vector4, type Camera, type Object3D, type Plane, type Vector2Like } from \"three\";\n\n/** One volume of a frame volume: the per-render state his `FrameVolume.volumes[i]` holds. */\nexport interface FrameVolumeRecord {\n readonly matrix: Matrix4;\n readonly matrixWorld: Matrix4;\n readonly localToView: Matrix4;\n readonly viewToLocal: Matrix4;\n readonly worldToLocal: Matrix4;\n readonly worldBox: Box3;\n viewNear: number;\n viewFar: number;\n ready: boolean;\n}\n\n/** What the collector needs of a frame volume. */\nexport interface FrameVolumeLike extends Object3D {\n readonly isVDBFrameVolume: true;\n readonly proxy: Object3D;\n readonly volumes: readonly FrameVolumeRecord[];\n readonly mipmaps: boolean;\n /** Re-reads the source (its uniforms and, for a sparse source's box, `volumes[].matrix`) if it changed. */\n syncSource?(): void;\n}\n\nexport interface FrameVolumeEntry<V extends FrameVolumeLike = FrameVolumeLike> {\n frameVolume: V;\n volume: FrameVolumeRecord;\n}\n\nconst unitBox = new Box3(new Vector3(-0.5, -0.5, -0.5), new Vector3(0.5, 0.5, 0.5));\nconst frustum = new Frustum();\nconst projectionScreenMatrix = new Matrix4();\nconst clipMatrix = new Matrix4();\nconst corner = new Vector4();\nconst viewFrustum = new Frustum();\nconst boxCorners = Array.from({ length: 8 }, () => new Vector3());\nconst clipPolygons = [Array.from({ length: 12 }, () => new Vector3()), Array.from({ length: 12 }, () => new Vector3())];\nconst clipDepths = { near: 0.0, far: 0.0 };\nconst frustumCorners = Array.from({ length: 8 }, () => new Vector3());\nconst localCorner = new Vector3();\nconst crossA = new Vector3();\nconst crossB = new Vector3();\nconst crossC = new Vector3();\n\n// NOTE Point where three planes meet (normal . p + constant = 0 for each). Writes target.\nconst intersectPlanes = (a: Plane, b: Plane, c: Plane, target: Vector3) => {\n crossA.crossVectors(b.normal, c.normal);\n crossB.crossVectors(c.normal, a.normal);\n crossC.crossVectors(a.normal, b.normal);\n\n return target\n .copy(crossA)\n .multiplyScalar(-a.constant)\n .addScaledVector(crossB, -b.constant)\n .addScaledVector(crossC, -c.constant)\n .divideScalar(a.normal.dot(crossA));\n};\n\n// NOTE Corners of the view space frustum. The planes of Frustum are in pairs: x (0, 1), y (2, 3) and z (4, 5).\nconst setFrustumCorners = (planes: Plane[]) => {\n for (let i = 0; i < 8; i++) {\n intersectPlanes(planes[i & 1]!, planes[2 + ((i >> 1) & 1)]!, planes[4 + ((i >> 2) & 1)]!, frustumCorners[i]!);\n }\n};\n\n// NOTE Corners of each face of the unit box, in order around the face (corner bits: 1 x, 2 y, 4 z)\nconst boxFaces = [\n [0, 2, 6, 4],\n [1, 3, 7, 5],\n [0, 1, 5, 4],\n [2, 3, 7, 6],\n [0, 1, 3, 2],\n [4, 5, 7, 6],\n];\n\nconst setBoxCorners = (localToView: Matrix4) => {\n for (let i = 0; i < 8; i++) {\n boxCorners[i]!.set(i & 1 ? 0.5 : -0.5, i & 2 ? 0.5 : -0.5, i & 4 ? 0.5 : -0.5).applyMatrix4(localToView);\n }\n};\n\n// NOTE View depth range of the part of the box inside the view space frustum. The faces of the box are clipped to the\n// planes, so a box that reaches behind the camera or past the side of the view does not widen the range. The frustum\n// corners inside the box are the other corners of that part: with the camera in the box the range starts at the near\n// plane. Writes clipDepths and returns false when no part of the box is in the frustum.\nconst getClippedDepths = (clipFrustum: Frustum, viewToLocal: Matrix4) => {\n let near = Infinity;\n let far = -Infinity;\n\n for (let i = 0; i < 8; i++) {\n localCorner.copy(frustumCorners[i]!).applyMatrix4(viewToLocal);\n\n if (unitBox.containsPoint(localCorner)) {\n near = Math.min(near, -frustumCorners[i]!.z);\n far = Math.max(far, -frustumCorners[i]!.z);\n }\n }\n\n for (let f = 0; f < 6; f++) {\n let input = clipPolygons[0]!;\n let output = clipPolygons[1]!;\n let count = 4;\n\n for (let i = 0; i < 4; i++) {\n input[i]!.copy(boxCorners[boxFaces[f]![i]!]!);\n }\n\n for (let p = 0; p < 6 && count > 0; p++) {\n const plane = clipFrustum.planes[p]!;\n let outputCount = 0;\n\n for (let i = 0; i < count; i++) {\n const a = input[i]!;\n const b = input[(i + 1) % count]!;\n const da = plane.distanceToPoint(a);\n const db = plane.distanceToPoint(b);\n\n if (da >= 0.0) {\n output[outputCount++]!.copy(a);\n }\n\n if (da >= 0.0 !== db >= 0.0) {\n output[outputCount++]!.lerpVectors(a, b, da / (da - db));\n }\n }\n\n count = outputCount;\n [input, output] = [output, input];\n }\n\n for (let i = 0; i < count; i++) {\n near = Math.min(near, -input[i]!.z);\n far = Math.max(far, -input[i]!.z);\n }\n }\n\n clipDepths.near = near;\n clipDepths.far = far;\n\n return near <= far;\n};\n\n/**\n * Finds the ready volumes of the visible frame volumes (his `FrameVolumeCollector`). `volumes`: in\n * the view. `casters`: all, when `useGrid` (the 'frame' lighting shadow grid, K3.3). Entries and\n * arrays are reused by the next `collect()`.\n */\nexport class FrameVolumeCollector<V extends FrameVolumeLike = FrameVolumeLike> {\n volumes: FrameVolumeEntry<V>[] = [];\n casters: FrameVolumeEntry<V>[] = [];\n // NOTE View depth range of the volumes in the view\n near = 0.0;\n far = 0.0;\n\n entries: FrameVolumeEntry<V>[] = [];\n usedEntries = 0;\n camera: Camera | null = null;\n useGrid = false;\n prepareVolume: ((frameVolume: V, volume: FrameVolumeRecord) => void) | null = null;\n private readonly visitObject: (object: Object3D) => void;\n\n constructor() {\n this.visitObject = (object) => {\n const frameVolume = object as V;\n\n if (!frameVolume.isVDBFrameVolume || !frameVolume.proxy.layers.test(this.camera!.layers)) {\n return;\n }\n\n // G16a: a source that follows its grid's image may move the volume's box; re-read it before placing the box\n frameVolume.syncSource?.();\n\n const { volumes } = frameVolume;\n\n for (let i = 0; i < volumes.length; i++) {\n this.addVolume(frameVolume, volumes[i]!);\n }\n };\n }\n\n getEntry(frameVolume: V, volume: FrameVolumeRecord): FrameVolumeEntry<V> {\n if (this.usedEntries === this.entries.length) {\n this.entries.push({ frameVolume, volume });\n }\n\n const entry = this.entries[this.usedEntries++]!;\n\n entry.frameVolume = frameVolume;\n entry.volume = volume;\n\n return entry;\n }\n\n addVolume(frameVolume: V, volume: FrameVolumeRecord): void {\n if (!volume.ready) {\n return;\n }\n\n const camera = this.camera!;\n\n this.prepareVolume?.(frameVolume, volume);\n\n volume.matrixWorld.multiplyMatrices(frameVolume.matrixWorld, volume.matrix);\n volume.worldToLocal.copy(volume.matrixWorld).invert();\n volume.worldBox.copy(unitBox).applyMatrix4(volume.matrixWorld);\n\n const entry = this.getEntry(frameVolume, volume);\n\n // NOTE Volumes out of the view can still cast shadows on visible volumes\n if (this.useGrid) {\n this.casters.push(entry);\n }\n\n if (!frustum.intersectsBox(volume.worldBox)) {\n return;\n }\n\n volume.localToView.multiplyMatrices(camera.matrixWorldInverse, volume.matrixWorld);\n volume.viewToLocal.copy(volume.localToView).invert();\n setBoxCorners(volume.localToView);\n\n if (!getClippedDepths(viewFrustum, volume.viewToLocal)) {\n return;\n }\n\n volume.viewNear = clipDepths.near;\n volume.viewFar = clipDepths.far;\n\n this.near = Math.min(this.near, volume.viewNear);\n this.far = Math.max(this.far, volume.viewFar);\n\n this.volumes.push(entry);\n }\n\n /** settings: near and far of the renderer settings. Returns this; `volumes` is empty when none is in view. */\n collect(\n scene: Object3D,\n camera: Camera & { near: number; far: number; reversedDepth?: boolean },\n settings: { near: number; far: number },\n useGrid: boolean,\n prepareVolume: ((frameVolume: V, volume: FrameVolumeRecord) => void) | null = null,\n ): this {\n this.volumes.length = 0;\n this.casters.length = 0;\n this.usedEntries = 0;\n this.near = Infinity;\n this.far = 0.0;\n this.camera = camera;\n this.useGrid = useGrid;\n this.prepareVolume = prepareVolume;\n\n projectionScreenMatrix.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse);\n frustum.setFromProjectionMatrix(projectionScreenMatrix);\n viewFrustum.setFromProjectionMatrix(camera.projectionMatrix, camera.coordinateSystem, camera.reversedDepth);\n setFrustumCorners(viewFrustum.planes);\n\n scene.traverseVisible(this.visitObject);\n\n // NOTE Fit the slices to the visible volumes. Then no slices are used for empty space.\n this.near = Math.max(this.near, settings.near, camera.near);\n this.far = Math.min(this.far, settings.far, camera.far);\n\n if (this.far <= this.near) {\n this.volumes.length = 0;\n }\n\n this.far = Math.max(this.far, this.near * 1.0001);\n this.camera = null;\n this.prepareVolume = null;\n\n return this;\n }\n\n /** True when a volume in the view or a caster uses mipmaps. */\n hasMipmaps(): boolean {\n return hasMipmaps(this.volumes) || hasMipmaps(this.casters);\n }\n}\n\nconst hasMipmaps = (items: readonly FrameVolumeEntry[]) => {\n for (let i = 0; i < items.length; i++) {\n if (items[i]!.frameVolume.mipmaps) {\n return true;\n }\n }\n\n return false;\n};\n\n/** Uniform value of settings.fadeRadius. 0 turns the distance fade off. */\nexport const getFrameFadeRadius = (settings: { fadeRadius: number }) =>\n Number.isFinite(settings.fadeRadius) && settings.fadeRadius > 0.0 ? settings.fadeRadius : 0.0;\n\n/** Fractional slice of a view depth. range: froxelRange (near, far). Slices are logarithmic. */\nexport const getFroxelSlice = (viewDepth: number, range: Vector2Like, depth: number) =>\n (depth * Math.log(Math.max(viewDepth, range.x) / range.x)) / Math.log(range.y / range.x);\n\n/** First slice and slice count of a volume. Writes target ({ first, count }) and returns it. */\nexport const getFroxelSliceRange = (\n volume: { viewNear: number; viewFar: number },\n range: Vector2Like,\n depth: number,\n target: { first: number; count: number },\n) => {\n const first = Math.max(0, Math.floor(getFroxelSlice(volume.viewNear, range, depth)));\n const last = Math.min(depth - 1, Math.ceil(getFroxelSlice(volume.viewFar, range, depth)));\n\n target.first = first;\n target.count = last - first + 1;\n\n return target;\n};\n\n/**\n * Screen rectangle of the volume in froxel cells (x0, y0, x1, y1), with one cell of padding for the\n * linear filter. Writes target. Returns false when the volume covers no cell.\n */\nexport const getFroxelRect = (\n volume: { localToView: Matrix4 },\n camera: Camera,\n width: number,\n height: number,\n target: Vector4,\n) => {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n clipMatrix.multiplyMatrices(camera.projectionMatrix, volume.localToView);\n\n for (let i = 0; i < 8; i++) {\n corner.set(i & 1 ? 0.5 : -0.5, i & 2 ? 0.5 : -0.5, i & 4 ? 0.5 : -0.5, 1.0).applyMatrix4(clipMatrix);\n\n // NOTE A corner behind the camera: the volume can cover all of the screen\n if (corner.w <= 1e-6) {\n target.set(0.0, 0.0, width, height);\n\n return true;\n }\n\n minX = Math.min(minX, corner.x / corner.w);\n minY = Math.min(minY, corner.y / corner.w);\n maxX = Math.max(maxX, corner.x / corner.w);\n maxY = Math.max(maxY, corner.y / corner.w);\n }\n\n const x0 = Math.max(0, Math.floor((minX * 0.5 + 0.5) * width) - 1);\n const y0 = Math.max(0, Math.floor((minY * 0.5 + 0.5) * height) - 1);\n const x1 = Math.min(width, Math.ceil((maxX * 0.5 + 0.5) * width) + 1);\n const y1 = Math.min(height, Math.ceil((maxY * 0.5 + 0.5) * height) + 1);\n\n if (x1 <= x0 || y1 <= y0) {\n return false;\n }\n\n target.set(x0, y0, x1, y1);\n\n return true;\n};\n\nconst volumeRect = new Vector4();\nconst volumeSlices = { first: 0, count: 0 };\n\nexport interface FroxelArea {\n rect: Vector4;\n first: number;\n count: number;\n}\n\n/**\n * Froxel area of all volumes: the union of their rectangles and slices, one cell and one slice\n * larger on each side. Writes area; count is 0 when no volume covers a cell.\n */\nexport const getFroxelArea = (\n volumes: readonly { volume: { localToView: Matrix4; viewNear: number; viewFar: number } }[],\n camera: Camera,\n width: number,\n height: number,\n range: Vector2Like,\n depth: number,\n area: FroxelArea,\n) => {\n let x0 = Infinity;\n let y0 = Infinity;\n let x1 = -Infinity;\n let y1 = -Infinity;\n let first = Infinity;\n let last = -Infinity;\n\n for (let i = 0; i < volumes.length; i++) {\n const { volume } = volumes[i]!;\n\n if (!getFroxelRect(volume, camera, width, height, volumeRect)) {\n continue;\n }\n\n getFroxelSliceRange(volume, range, depth, volumeSlices);\n\n x0 = Math.min(x0, volumeRect.x);\n y0 = Math.min(y0, volumeRect.y);\n x1 = Math.max(x1, volumeRect.z);\n y1 = Math.max(y1, volumeRect.w);\n first = Math.min(first, volumeSlices.first);\n last = Math.max(last, volumeSlices.first + volumeSlices.count - 1);\n }\n\n if (first > last) {\n area.rect.set(0.0, 0.0, 0.0, 0.0);\n area.first = 0;\n area.count = 0;\n\n return area;\n }\n\n area.rect.set(Math.max(0, x0 - 1), Math.max(0, y0 - 1), Math.min(width, x1 + 1), Math.min(height, y1 + 1));\n area.first = Math.max(0, first - 1);\n area.count = Math.min(depth - 1, last + 1) - area.first + 1;\n\n return area;\n};\n"]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { NodeMaterial } from "three/webgpu";
|
|
2
|
-
import type { VDBTslNode } from "../grid-node.js";
|
|
3
|
-
import { type GridUniforms } from "./chunks.js";
|
|
4
|
-
import { frameMaxCastShadowSteps } from "../../tools/frame/shadows.js";
|
|
5
|
-
type N = VDBTslNode;
|
|
6
|
-
export { frameMaxCastShadowSteps };
|
|
7
|
-
/** Ray uniforms of one light shadow camera; the pass and the receivers measure depth with them. */
|
|
8
|
-
export declare const createShadowRayUniforms: () => {
|
|
9
|
-
frameShadowOrigin: any;
|
|
10
|
-
frameShadowForward: any;
|
|
11
|
-
frameShadowPerspective: any;
|
|
12
|
-
frameShadowFar: any;
|
|
13
|
-
};
|
|
14
|
-
export type ShadowRayUniforms = {
|
|
15
|
-
frameShadowOrigin: N;
|
|
16
|
-
frameShadowForward: N;
|
|
17
|
-
frameShadowPerspective: N;
|
|
18
|
-
frameShadowFar: N;
|
|
19
|
-
};
|
|
20
|
-
/** Depth of a world position: the distance from the light (perspective) or from the camera plane (orthographic). */
|
|
21
|
-
export declare const frameShadowDepth: (rayUniforms: ShadowRayUniforms, worldPosition: N) => N;
|
|
22
|
-
export declare class VDBFrameVolumeShadowMaterial extends NodeMaterial {
|
|
23
|
-
readonly frameShadowDensityMap: any;
|
|
24
|
-
readonly frameShadowSteps: any;
|
|
25
|
-
readonly frameShadowOutput: any;
|
|
26
|
-
readonly frameUniforms: {
|
|
27
|
-
gridUniforms: GridUniforms;
|
|
28
|
-
rayUniforms: ShadowRayUniforms;
|
|
29
|
-
};
|
|
30
|
-
spectral: boolean;
|
|
31
|
-
constructor(o: {
|
|
32
|
-
gridUniforms: GridUniforms;
|
|
33
|
-
}, rayUniforms: ShadowRayUniforms);
|
|
34
|
-
setSpectral(spectral: boolean): void;
|
|
35
|
-
createFragmentNode(): N;
|
|
36
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):
|
|
2
|
-
// src/three-openvdb/frame/webgpu/FrameVolumeShadowMaterial.js L27–173 (constants, createShadowRayUniforms,
|
|
3
|
-
// frameShadowDepth, the Beer shadow map pass with its spectral outputs).
|
|
4
|
-
// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).
|
|
5
|
-
// Changes: TypeScript; reads the world shadow grid through our grid chunks (`createGridNodes`); source-free, so one
|
|
6
|
-
// material serves every volume source. CPU twin: `@pmndrs/vdb/tools` `vdbFrameShadowMapTexel`.
|
|
7
|
-
// Divergences: none.
|
|
8
|
-
/**
|
|
9
|
-
* K3.6: the Beer shadow map of all volumes for one light (his `FrameVolumeShadowMaterial`), from the world shadow
|
|
10
|
-
* grid. A fullscreen pass in the light's shadow camera: each texel marches its light ray through the last grid
|
|
11
|
-
* cascade (all volumes; it does not move with the camera, so the cost is fixed) with `frameShadowSteps` samples.
|
|
12
|
-
* Texel: (τ·first depth, τ·last depth, 0, τ), depths ÷ far (half-float precision); empty texels are 0, so the
|
|
13
|
-
* linear filter of the map is right. Spectral: two draws; output 0 has the channel mean, output 1 (τ rgb, 0).
|
|
14
|
-
*/
|
|
15
|
-
import * as THREE from "three";
|
|
16
|
-
import { NodeMaterial } from "three/webgpu";
|
|
17
|
-
import * as TSL from "three/tsl";
|
|
18
|
-
import { createGridNodes } from "./chunks.js";
|
|
19
|
-
import { frameMaxCastShadowSteps, frameShadowMaxOpticalDepth } from "../../tools/frame/shadows.js";
|
|
20
|
-
const { Break, Fn, If, Loop, cameraPosition, cameraProjectionMatrix, cameraProjectionMatrixInverse, cameraWorldMatrix, dot, float, length, max, min, normalize, positionGeometry, select, texture, uniform, varying, vec3, vec4 } = TSL;
|
|
21
|
-
export { frameMaxCastShadowSteps };
|
|
22
|
-
/** Ray uniforms of one light shadow camera; the pass and the receivers measure depth with them. */
|
|
23
|
-
export const createShadowRayUniforms = () => ({
|
|
24
|
-
frameShadowOrigin: uniform(new THREE.Vector3()),
|
|
25
|
-
frameShadowForward: uniform(new THREE.Vector3(0.0, 0.0, -1.0)),
|
|
26
|
-
frameShadowPerspective: uniform(0, "int"),
|
|
27
|
-
frameShadowFar: uniform(1.0),
|
|
28
|
-
});
|
|
29
|
-
/** Depth of a world position: the distance from the light (perspective) or from the camera plane (orthographic). */
|
|
30
|
-
export const frameShadowDepth = (rayUniforms, worldPosition) => {
|
|
31
|
-
const { frameShadowOrigin, frameShadowForward, frameShadowPerspective } = rayUniforms;
|
|
32
|
-
const offset = worldPosition.sub(frameShadowOrigin);
|
|
33
|
-
return select(frameShadowPerspective.equal(1), length(offset), dot(offset, frameShadowForward));
|
|
34
|
-
};
|
|
35
|
-
export class VDBFrameVolumeShadowMaterial extends NodeMaterial {
|
|
36
|
-
frameShadowDensityMap = texture(new THREE.Texture());
|
|
37
|
-
frameShadowSteps = uniform(32, "int");
|
|
38
|
-
frameShadowOutput = uniform(0, "int");
|
|
39
|
-
frameUniforms;
|
|
40
|
-
spectral = false;
|
|
41
|
-
constructor(o, rayUniforms) {
|
|
42
|
-
super();
|
|
43
|
-
this.name = "VDBFrameVolumeShadowMaterial";
|
|
44
|
-
this.frameUniforms = { gridUniforms: o.gridUniforms, rayUniforms };
|
|
45
|
-
this.vertexNode = vec4(positionGeometry.xy, 0.0, 1.0);
|
|
46
|
-
this.fragmentNode = this.createFragmentNode();
|
|
47
|
-
this.depthTest = false;
|
|
48
|
-
this.depthWrite = false;
|
|
49
|
-
this.blending = THREE.NoBlending;
|
|
50
|
-
}
|
|
51
|
-
setSpectral(spectral) {
|
|
52
|
-
if (spectral !== this.spectral) {
|
|
53
|
-
this.spectral = spectral;
|
|
54
|
-
this.fragmentNode = this.createFragmentNode();
|
|
55
|
-
this.needsUpdate = true;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
createFragmentNode() {
|
|
59
|
-
const { spectral } = this;
|
|
60
|
-
const { gridUniforms, rayUniforms } = this.frameUniforms;
|
|
61
|
-
const grid = createGridNodes(gridUniforms);
|
|
62
|
-
const { frameGridMin, frameGridSize, frameGridCount } = gridUniforms;
|
|
63
|
-
const { frameShadowFar } = rayUniforms;
|
|
64
|
-
const ndc = varying(positionGeometry.xy);
|
|
65
|
-
// NOTE World position of a point on the pixel ray of the current camera
|
|
66
|
-
const unproject = (z) => {
|
|
67
|
-
const view = cameraProjectionMatrixInverse.mul(vec4(ndc, z, 1.0));
|
|
68
|
-
const world = cameraWorldMatrix.mul(vec4(view.xyz.div(view.w), 1.0));
|
|
69
|
-
return world.xyz;
|
|
70
|
-
};
|
|
71
|
-
return Fn(() => {
|
|
72
|
-
// NOTE Two points in the depth range of all backends give the ray direction
|
|
73
|
-
const near = unproject(float(0.25)).toVar();
|
|
74
|
-
const direction = normalize(unproject(float(0.75)).sub(near)).toVar();
|
|
75
|
-
const perspective = cameraProjectionMatrix.element(3).w.lessThan(0.5);
|
|
76
|
-
// NOTE Perspective rays start at the light. Orthographic rays start on the camera plane.
|
|
77
|
-
const origin = select(perspective, cameraPosition, near.sub(direction.mul(dot(near.sub(cameraPosition), direction)))).toVar();
|
|
78
|
-
// NOTE Spectral: optical depth of each channel
|
|
79
|
-
const opticalDepth = (spectral ? vec3(0.0) : float(0.0)).toVar();
|
|
80
|
-
const first = float(0.0).toVar();
|
|
81
|
-
const last = float(0.0).toVar();
|
|
82
|
-
If(frameGridCount.greaterThan(0), () => {
|
|
83
|
-
const cascade = frameGridCount.sub(1).toVar();
|
|
84
|
-
const boxMin = frameGridMin.element(cascade);
|
|
85
|
-
const boxMax = boxMin.add(frameGridSize.element(cascade));
|
|
86
|
-
const inverseDirection = vec3(1.0).div(direction);
|
|
87
|
-
const tA = boxMin.sub(origin).mul(inverseDirection);
|
|
88
|
-
const tB = boxMax.sub(origin).mul(inverseDirection);
|
|
89
|
-
const tMin = min(tA, tB);
|
|
90
|
-
const tMax = max(tA, tB);
|
|
91
|
-
const tStart = max(0.0, max(tMin.x, max(tMin.y, tMin.z))).toVar();
|
|
92
|
-
const tEnd = min(tMax.x, min(tMax.y, tMax.z)).toVar();
|
|
93
|
-
If(tEnd.greaterThan(tStart), () => {
|
|
94
|
-
const steps = max(this.frameShadowSteps, 1);
|
|
95
|
-
const stepLength = tEnd.sub(tStart).div(float(steps)).toVar();
|
|
96
|
-
const firstT = float(-1.0).toVar();
|
|
97
|
-
const lastT = float(-1.0).toVar();
|
|
98
|
-
Loop(steps, ({ i }) => {
|
|
99
|
-
If((spectral ? min(opticalDepth.x, min(opticalDepth.y, opticalDepth.z)) : opticalDepth).greaterThan(frameShadowMaxOpticalDepth), () => {
|
|
100
|
-
Break();
|
|
101
|
-
});
|
|
102
|
-
const t = tStart.add(float(i).mul(stepLength)).toVar();
|
|
103
|
-
const sample = origin.add(direction.mul(t.add(stepLength.mul(0.5))));
|
|
104
|
-
const gridSample = grid.sampleGrid(this.frameShadowDensityMap, cascade, grid.gridUvw(cascade, sample));
|
|
105
|
-
const extinction = (spectral ? gridSample.rgb : gridSample.r).toVar();
|
|
106
|
-
If((spectral ? dot(extinction, vec3(1.0)) : extinction).greaterThan(0.0), () => {
|
|
107
|
-
If(firstT.lessThan(0.0), () => {
|
|
108
|
-
firstT.assign(t);
|
|
109
|
-
});
|
|
110
|
-
lastT.assign(t.add(stepLength));
|
|
111
|
-
opticalDepth.addAssign(extinction.mul(stepLength));
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
If((spectral ? dot(opticalDepth, vec3(1.0)) : opticalDepth).greaterThan(0.0), () => {
|
|
115
|
-
first.assign(frameShadowDepth(rayUniforms, origin.add(direction.mul(firstT))).div(frameShadowFar));
|
|
116
|
-
last.assign(frameShadowDepth(rayUniforms, origin.add(direction.mul(lastT))).div(frameShadowFar));
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
if (spectral) {
|
|
121
|
-
const meanDepth = dot(opticalDepth, vec3(1.0 / 3.0)).toVar();
|
|
122
|
-
return select(this.frameShadowOutput.equal(1), vec4(opticalDepth, 0.0), vec4(first.mul(meanDepth), last.mul(meanDepth), 0.0, meanDepth));
|
|
123
|
-
}
|
|
124
|
-
return vec4(first.mul(opticalDepth), last.mul(opticalDepth), 0.0, opticalDepth);
|
|
125
|
-
})();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
//# sourceMappingURL=volume-shadow-material.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"volume-shadow-material.js","sourceRoot":"","sources":["../../../src/three/frame/volume-shadow-material.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,6GAA6G;AAC7G,2EAA2E;AAC3E,4GAA4G;AAC5G,oHAAoH;AACpH,+FAA+F;AAC/F,qBAAqB;AAErB;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,eAAe,EAAqB,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAEn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AAc,CAAC,CAAC,CAAC;oBACnG,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,SAAS,GAAG,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;gBAE7D,OAAO,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;YAC3I,CAAC;YAED,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;QAClF,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;CACF","sourcesContent":["// Portions derived from mjurczyk/openvdb (MIT), commit 75e7345 (v0.26.0):\n// src/three-openvdb/frame/webgpu/FrameVolumeShadowMaterial.js L27–173 (constants, createShadowRayUniforms,\n// frameShadowDepth, the Beer shadow map pass with its spectral outputs).\n// Copyright (c) mjurczyk/openvdb contributors. Licensed under the MIT License (see THIRD_PARTY_NOTICES.md).\n// Changes: TypeScript; reads the world shadow grid through our grid chunks (`createGridNodes`); source-free, so one\n// material serves every volume source. CPU twin: `@pmndrs/vdb/tools` `vdbFrameShadowMapTexel`.\n// Divergences: none.\n\n/**\n * K3.6: the Beer shadow map of all volumes for one light (his `FrameVolumeShadowMaterial`), from the world shadow\n * grid. A fullscreen pass in the light's shadow camera: each texel marches its light ray through the last grid\n * cascade (all volumes; it does not move with the camera, so the cost is fixed) with `frameShadowSteps` samples.\n * Texel: (τ·first depth, τ·last depth, 0, τ), depths ÷ far (half-float precision); empty texels are 0, so the\n * linear filter of the map is right. Spectral: two draws; output 0 has the channel mean, output 1 (τ rgb, 0).\n */\n\nimport * as THREE from \"three\";\nimport { NodeMaterial } from \"three/webgpu\";\nimport * as TSL from \"three/tsl\";\nimport type { VDBTslNode } from \"../grid-node.js\";\nimport { createGridNodes, type GridUniforms } from \"./chunks.js\";\nimport { frameMaxCastShadowSteps, frameShadowMaxOpticalDepth } from \"../../tools/frame/shadows.js\";\n\nconst { Break, Fn, If, Loop, cameraPosition, cameraProjectionMatrix, cameraProjectionMatrixInverse, cameraWorldMatrix, dot, float, length, max, min, normalize, positionGeometry, select, texture, uniform, varying, vec3, vec4 } =\n TSL as unknown as Record<string, VDBTslNode>;\n\ntype N = VDBTslNode;\n\nexport { frameMaxCastShadowSteps };\n\n/** Ray uniforms of one light shadow camera; the pass and the receivers measure depth with them. */\nexport const createShadowRayUniforms = () => ({\n frameShadowOrigin: uniform(new THREE.Vector3()),\n frameShadowForward: uniform(new THREE.Vector3(0.0, 0.0, -1.0)),\n frameShadowPerspective: uniform(0, \"int\"),\n frameShadowFar: uniform(1.0),\n});\n\nexport type ShadowRayUniforms = { frameShadowOrigin: N; frameShadowForward: N; frameShadowPerspective: N; frameShadowFar: N };\n\n/** Depth of a world position: the distance from the light (perspective) or from the camera plane (orthographic). */\nexport const frameShadowDepth = (rayUniforms: ShadowRayUniforms, worldPosition: N): N => {\n const { frameShadowOrigin, frameShadowForward, frameShadowPerspective } = rayUniforms;\n const offset = worldPosition.sub(frameShadowOrigin);\n\n return select(frameShadowPerspective.equal(1), length(offset), dot(offset, frameShadowForward));\n};\n\nexport class VDBFrameVolumeShadowMaterial extends NodeMaterial {\n readonly frameShadowDensityMap = texture(new THREE.Texture());\n readonly frameShadowSteps = uniform(32, \"int\");\n readonly frameShadowOutput = uniform(0, \"int\");\n readonly frameUniforms: { gridUniforms: GridUniforms; rayUniforms: ShadowRayUniforms };\n spectral = false;\n\n constructor(o: { gridUniforms: GridUniforms }, rayUniforms: ShadowRayUniforms) {\n super();\n\n this.name = \"VDBFrameVolumeShadowMaterial\";\n this.frameUniforms = { gridUniforms: o.gridUniforms, rayUniforms };\n this.vertexNode = vec4(positionGeometry.xy, 0.0, 1.0);\n this.fragmentNode = this.createFragmentNode();\n\n this.depthTest = false;\n this.depthWrite = false;\n this.blending = THREE.NoBlending;\n }\n\n setSpectral(spectral: boolean): void {\n if (spectral !== this.spectral) {\n this.spectral = spectral;\n this.fragmentNode = this.createFragmentNode();\n this.needsUpdate = true;\n }\n }\n\n createFragmentNode(): N {\n const { spectral } = this;\n const { gridUniforms, rayUniforms } = this.frameUniforms;\n const grid = createGridNodes(gridUniforms);\n const { frameGridMin, frameGridSize, frameGridCount } = gridUniforms;\n const { frameShadowFar } = rayUniforms;\n const ndc = varying(positionGeometry.xy);\n\n // NOTE World position of a point on the pixel ray of the current camera\n const unproject = (z: N): N => {\n const view = cameraProjectionMatrixInverse.mul(vec4(ndc, z, 1.0));\n const world = cameraWorldMatrix.mul(vec4(view.xyz.div(view.w), 1.0));\n\n return world.xyz;\n };\n\n return Fn(() => {\n // NOTE Two points in the depth range of all backends give the ray direction\n const near = unproject(float(0.25)).toVar();\n const direction = normalize(unproject(float(0.75)).sub(near)).toVar();\n const perspective = cameraProjectionMatrix.element(3).w.lessThan(0.5);\n\n // NOTE Perspective rays start at the light. Orthographic rays start on the camera plane.\n const origin = select(perspective, cameraPosition, near.sub(direction.mul(dot(near.sub(cameraPosition), direction)))).toVar();\n\n // NOTE Spectral: optical depth of each channel\n const opticalDepth = (spectral ? vec3(0.0) : float(0.0)).toVar();\n const first = float(0.0).toVar();\n const last = float(0.0).toVar();\n\n If(frameGridCount.greaterThan(0), () => {\n const cascade = frameGridCount.sub(1).toVar();\n const boxMin = frameGridMin.element(cascade);\n const boxMax = boxMin.add(frameGridSize.element(cascade));\n const inverseDirection = vec3(1.0).div(direction);\n const tA = boxMin.sub(origin).mul(inverseDirection);\n const tB = boxMax.sub(origin).mul(inverseDirection);\n const tMin = min(tA, tB);\n const tMax = max(tA, tB);\n const tStart = max(0.0, max(tMin.x, max(tMin.y, tMin.z))).toVar();\n const tEnd = min(tMax.x, min(tMax.y, tMax.z)).toVar();\n\n If(tEnd.greaterThan(tStart), () => {\n const steps = max(this.frameShadowSteps, 1);\n const stepLength = tEnd.sub(tStart).div(float(steps)).toVar();\n const firstT = float(-1.0).toVar();\n const lastT = float(-1.0).toVar();\n\n Loop(steps, ({ i }: { i: N }) => {\n If((spectral ? min(opticalDepth.x, min(opticalDepth.y, opticalDepth.z)) : opticalDepth).greaterThan(frameShadowMaxOpticalDepth), () => {\n Break();\n });\n\n const t = tStart.add(float(i).mul(stepLength)).toVar();\n const sample = origin.add(direction.mul(t.add(stepLength.mul(0.5))));\n const gridSample = grid.sampleGrid(this.frameShadowDensityMap, cascade, grid.gridUvw(cascade, sample));\n const extinction = (spectral ? gridSample.rgb : gridSample.r).toVar();\n\n If((spectral ? dot(extinction, vec3(1.0)) : extinction).greaterThan(0.0), () => {\n If(firstT.lessThan(0.0), () => {\n firstT.assign(t);\n });\n\n lastT.assign(t.add(stepLength));\n opticalDepth.addAssign(extinction.mul(stepLength));\n });\n });\n\n If((spectral ? dot(opticalDepth, vec3(1.0)) : opticalDepth).greaterThan(0.0), () => {\n first.assign(frameShadowDepth(rayUniforms, origin.add(direction.mul(firstT))).div(frameShadowFar));\n last.assign(frameShadowDepth(rayUniforms, origin.add(direction.mul(lastT))).div(frameShadowFar));\n });\n });\n });\n\n if (spectral) {\n const meanDepth = dot(opticalDepth, vec3(1.0 / 3.0)).toVar();\n\n return select(this.frameShadowOutput.equal(1), vec4(opticalDepth, 0.0), vec4(first.mul(meanDepth), last.mul(meanDepth), 0.0, meanDepth));\n }\n\n return vec4(first.mul(opticalDepth), last.mul(opticalDepth), 0.0, opticalDepth);\n })();\n }\n}\n"]}
|