@woosh/meep-engine 2.107.0 → 2.108.2
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/build/bundle-worker-image-decoder.js +1 -1
- package/build/meep.cjs +255 -172
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +255 -173
- package/editor/tools/paint/TerrainHeightPaintTool.js +5 -5
- package/package.json +1 -1
- package/src/core/binary/float_to_uint8.d.ts +7 -0
- package/src/core/binary/float_to_uint8.d.ts.map +1 -0
- package/src/core/binary/{float2uint8.js → float_to_uint8.js} +1 -1
- package/src/core/binary/int32_to_binary_string.d.ts +3 -2
- package/src/core/binary/int32_to_binary_string.d.ts.map +1 -1
- package/src/core/binary/int32_to_binary_string.js +18 -14
- package/src/core/binary/split_by_3.spec.d.ts +2 -0
- package/src/core/binary/split_by_3.spec.d.ts.map +1 -0
- package/src/core/binary/split_by_3.spec.js +22 -0
- package/src/core/binary/to_half_float_uint16.d.ts.map +1 -1
- package/src/core/binary/to_half_float_uint16.js +7 -5
- package/src/core/binary/uint8_to_float.d.ts +7 -0
- package/src/core/binary/uint8_to_float.d.ts.map +1 -0
- package/src/core/binary/{uint82float.js → uint8_to_float.js} +1 -1
- package/src/core/binary/uint8_to_float.spec.d.ts +2 -0
- package/src/core/binary/uint8_to_float.spec.d.ts.map +1 -0
- package/src/core/binary/uint8_to_float.spec.js +7 -0
- package/src/core/codegen/codeToBlob.d.ts +8 -0
- package/src/core/codegen/codeToBlob.d.ts.map +1 -0
- package/src/core/codegen/codeToBlob.js +36 -0
- package/src/core/codegen/codeToURL.d.ts +8 -0
- package/src/core/codegen/codeToURL.d.ts.map +1 -0
- package/src/core/codegen/codeToURL.js +22 -0
- package/src/core/collection/array/array_shuffle.d.ts +8 -0
- package/src/core/collection/array/array_shuffle.d.ts.map +1 -0
- package/src/core/collection/array/array_shuffle.js +22 -0
- package/src/core/collection/array/array_shuffle.spec.d.ts +2 -0
- package/src/core/collection/array/array_shuffle.spec.d.ts.map +1 -0
- package/src/core/collection/array/{randomizeArrayElementOrder.spec.js → array_shuffle.spec.js} +4 -4
- package/src/core/collection/array/isArrayEqualStrict.d.ts.map +1 -1
- package/src/core/collection/array/isArrayEqualStrict.js +2 -2
- package/src/core/collection/array/iterator/ArrayIteratorRandom.js +2 -2
- package/src/core/collection/array/randomMultipleFromArray.js +2 -2
- package/src/core/color/Color.d.ts.map +1 -1
- package/src/core/color/Color.js +16 -11
- package/src/core/color/hsv/hsv2rgb.js +4 -4
- package/src/core/color/hsv/rgb2hsv.d.ts +3 -3
- package/src/core/color/hsv/rgb2hsv.d.ts.map +1 -1
- package/src/core/color/hsv/rgb2hsv.js +11 -18
- package/src/core/color/rgb2uint24.js +4 -4
- package/src/core/color/rgb_to_luminance.d.ts +9 -0
- package/src/core/color/rgb_to_luminance.d.ts.map +1 -0
- package/src/core/color/rgb_to_luminance.js +10 -0
- package/src/core/color/sRGB/linear_to_sRGB.d.ts +1 -0
- package/src/core/color/sRGB/linear_to_sRGB.d.ts.map +1 -1
- package/src/core/color/sRGB/linear_to_sRGB.js +4 -4
- package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/AABB3.js +4 -1
- package/src/core/geom/3d/aabb/aabb3_intersects_ray.js +3 -3
- package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/UnitSphereShape3D.js +14 -14
- package/src/core/geom/3d/sphere/harmonics/README.md +16 -2
- package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.d.ts +6 -0
- package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/harmonics/SH3_COEFFICIENTS.js +17 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_basis_at.d.ts.map +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_basis_at.js +21 -9
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.d.ts +3 -3
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.d.ts.map +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +35 -206
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate.d.ts +8 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_rotate.js +29 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_sample_by_direction.js +10 -10
- package/src/core/geom/3d/sphere/harmonics/sh_index.d.ts +8 -0
- package/src/core/geom/3d/sphere/harmonics/sh_index.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/harmonics/sh_index.js +9 -0
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts +8 -0
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band1.js +44 -0
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts +8 -0
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/harmonics/sh_rotate_band2.js +86 -0
- package/src/core/geom/3d/sphere/in_sphere3d_robust.d.ts.map +1 -1
- package/src/core/geom/3d/sphere/in_sphere3d_robust.js +2 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts +20 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.js +53 -7
- package/src/core/geom/3d/tetrahedra/TetrahedralMesh.spec.js +2 -2
- package/src/core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.d.ts +1 -1
- package/src/core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.js +12 -7
- package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.d.ts +13 -0
- package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/delaunay/tetrahedral_mesh_build_from_grid.js +135 -0
- package/src/core/geom/3d/tetrahedra/prototypeTetrahedraBuilder.js +38 -24
- package/src/core/geom/3d/tetrahedra/{compute_circumsphere.d.ts → tetrahedron_compute_circumsphere.d.ts} +3 -5
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/{compute_circumsphere.js → tetrahedron_compute_circumsphere.js} +2 -4
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_signed_volume.js +3 -1
- package/src/core/geom/Vector3.d.ts.map +1 -1
- package/src/core/geom/Vector3.js +4 -3
- package/src/core/geom/mat3/m3_multiply_vec3.d.ts +8 -0
- package/src/core/geom/mat3/m3_multiply_vec3.d.ts.map +1 -0
- package/src/core/geom/mat3/m3_multiply_vec3.js +21 -0
- package/src/core/geom/random/randomPointInSphere.d.ts +1 -1
- package/src/core/geom/random/randomPointInSphere.js +2 -2
- package/src/core/geom/random/randomPointOnSphere.d.ts +3 -3
- package/src/core/geom/random/randomPointOnSphere.d.ts.map +1 -1
- package/src/core/geom/random/randomPointOnSphere.js +5 -9
- package/src/core/geom/vec2/v2_cross_product.d.ts +15 -0
- package/src/core/geom/vec2/v2_cross_product.d.ts.map +1 -0
- package/src/core/geom/vec2/v2_cross_product.js +21 -0
- package/src/core/geom/vec3/v3_slerp.d.ts +1 -0
- package/src/core/geom/vec3/v3_slerp.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_slerp.js +1 -0
- package/src/core/graph/MultiNode.d.ts +1 -1
- package/src/core/graph/MultiNode.js +1 -1
- package/src/core/graph/WeightedEdge.d.ts +6 -4
- package/src/core/graph/WeightedEdge.d.ts.map +1 -1
- package/src/core/graph/WeightedEdge.js +3 -0
- package/src/core/graph/coloring/colorizeGraph.js +19 -19
- package/src/core/graph/convert_graph_to_dot_string.d.ts +1 -1
- package/src/core/graph/convert_graph_to_dot_string.d.ts.map +1 -1
- package/src/core/graph/convert_graph_to_dot_string.js +10 -6
- package/src/core/graph/graph_compute_adjacency_matrix.d.ts +9 -0
- package/src/core/graph/graph_compute_adjacency_matrix.d.ts.map +1 -0
- package/src/core/graph/{graph_adjacency_matrix.js → graph_compute_adjacency_matrix.js} +1 -2
- package/src/core/graph/graph_compute_degree_matrix.d.ts +10 -0
- package/src/core/graph/graph_compute_degree_matrix.d.ts.map +1 -0
- package/src/core/graph/graph_compute_degree_matrix.js +23 -0
- package/src/core/graph/graph_compute_distance_matrix.d.ts +13 -0
- package/src/core/graph/graph_compute_distance_matrix.d.ts.map +1 -0
- package/src/core/graph/graph_compute_distance_matrix.js +103 -0
- package/src/core/graph/{graph_laplacian_matrix.d.ts → graph_compute_laplacian_matrix.d.ts} +2 -2
- package/src/core/graph/graph_compute_laplacian_matrix.d.ts.map +1 -0
- package/src/core/graph/{graph_laplacian_matrix.js → graph_compute_laplacian_matrix.js} +6 -6
- package/src/core/graph/graph_k_means_cluster.d.ts.map +1 -1
- package/src/core/graph/graph_k_means_cluster.js +4 -119
- package/src/core/graph/{coarsen_graph.d.ts → mn_graph_coarsen.d.ts} +2 -2
- package/src/core/graph/mn_graph_coarsen.d.ts.map +1 -0
- package/src/core/graph/{coarsen_graph.js → mn_graph_coarsen.js} +1 -1
- package/src/core/graph/mn_graph_coarsen.spec.d.ts +2 -0
- package/src/core/graph/mn_graph_coarsen.spec.d.ts.map +1 -0
- package/src/core/graph/{coarsen_graph.spec.js → mn_graph_coarsen.spec.js} +4 -4
- package/src/core/graph/mn_graph_collapse_weighted_edge.d.ts +1 -0
- package/src/core/graph/mn_graph_collapse_weighted_edge.d.ts.map +1 -1
- package/src/core/graph/mn_graph_collapse_weighted_edge.js +7 -1
- package/src/core/math/physics/brdf/brdf_burley.d.ts.map +1 -1
- package/src/core/math/physics/brdf/brdf_burley.js +9 -1
- package/src/core/math/physics/brdf/{D_GGX.d.ts → diffuse_GGX.d.ts} +2 -2
- package/src/core/math/physics/brdf/diffuse_GGX.d.ts.map +1 -0
- package/src/core/math/physics/brdf/{D_GGX.js → diffuse_GGX.js} +1 -1
- package/src/core/math/physics/brdf/fresnel_Schlick.d.ts +3 -0
- package/src/core/math/physics/brdf/fresnel_Schlick.d.ts.map +1 -0
- package/src/core/math/physics/brdf/fresnel_Schlick.js +3 -0
- package/src/core/math/physics/brdf/fresnel_Schlick_optimized.d.ts +9 -0
- package/src/core/math/physics/brdf/fresnel_Schlick_optimized.d.ts.map +1 -0
- package/src/core/math/physics/brdf/fresnel_Schlick_optimized.js +12 -0
- package/src/core/math/physics/brdf/fresnel_Schlick_original.d.ts +9 -0
- package/src/core/math/physics/brdf/fresnel_Schlick_original.d.ts.map +1 -0
- package/src/core/math/physics/brdf/fresnel_Schlick_original.js +10 -0
- package/src/core/math/physics/bsdf/bsdf_schlick.d.ts.map +1 -1
- package/src/core/math/physics/bsdf/bsdf_schlick.js +3 -11
- package/src/core/math/physics/ior_to_reflectivity.d.ts +7 -0
- package/src/core/math/physics/ior_to_reflectivity.d.ts.map +1 -0
- package/src/core/math/physics/ior_to_reflectivity.js +9 -0
- package/src/core/math/physics/pdf/README.md +1 -0
- package/src/core/math/physics/pdf/pdf_GGX.d.ts +16 -0
- package/src/core/math/physics/pdf/pdf_GGX.d.ts.map +1 -0
- package/src/core/math/physics/pdf/pdf_GGX.js +25 -0
- package/src/core/math/physics/reflectivity_to_ior.d.ts +7 -0
- package/src/core/math/physics/reflectivity_to_ior.d.ts.map +1 -0
- package/src/core/math/physics/reflectivity_to_ior.js +8 -0
- package/src/core/process/task/util/randomCountTask.js +3 -3
- package/src/core/process/worker/WorkerBuilder.d.ts.map +1 -1
- package/src/core/process/worker/WorkerBuilder.js +5 -35
- package/src/engine/EngineHarness.d.ts +10 -1
- package/src/engine/EngineHarness.d.ts.map +1 -1
- package/src/engine/EngineHarness.js +22 -11
- package/src/engine/asset/loaders/ArrayBufferLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/ArrayBufferLoader.js +17 -10
- package/src/engine/asset/loaders/image/png/PNGReader.d.ts +25 -11
- package/src/engine/asset/loaders/image/png/PNGReader.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/png/PNGReader.js +38 -24
- package/src/engine/asset/loaders/material/TextureAttachmensByMaterialType.d.ts.map +1 -1
- package/src/engine/asset/loaders/material/TextureAttachmensByMaterialType.js +5 -0
- package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +4 -4
- package/src/engine/graphics/GraphicsEngine.js +1 -1
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.d.ts.map +1 -1
- package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +4 -0
- package/src/engine/graphics/ecs/light/LightSystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/LightSystem.js +2 -3
- package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts +6 -0
- package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +22 -11
- package/src/engine/graphics/ecs/sprite/SpriteSystemPE.d.ts.map +1 -1
- package/src/engine/graphics/ecs/sprite/SpriteSystemPE.js +7 -7
- package/src/engine/graphics/impostors/octahedral/bake/prepare_bake_material.js +3 -3
- package/src/engine/graphics/render/forward_plus/model/DirectionalLight.d.ts.map +1 -1
- package/src/engine/graphics/render/forward_plus/model/DirectionalLight.js +25 -25
- package/src/engine/graphics/sh3/SH3VisualisationMaterial.d.ts.map +1 -1
- package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +9 -6
- package/src/engine/graphics/sh3/fromCubeRenderTarget.d.ts +9 -0
- package/src/engine/graphics/sh3/fromCubeRenderTarget.d.ts.map +1 -0
- package/src/engine/graphics/sh3/fromCubeRenderTarget.js +145 -0
- package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.d.ts +8 -0
- package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.d.ts.map +1 -0
- package/src/engine/graphics/sh3/gi/tetrahedral_mesh_to_texture.js +51 -0
- package/src/engine/graphics/sh3/{LightProbeVolume.d.ts → lpv/LightProbeVolume.d.ts} +18 -7
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +340 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.d.ts +18 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.js +44 -0
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +12 -0
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +122 -0
- package/src/engine/graphics/sh3/lpv/ProbeRenderer.d.ts +29 -0
- package/src/engine/graphics/sh3/lpv/ProbeRenderer.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/ProbeRenderer.js +35 -0
- package/src/engine/graphics/sh3/lpv/WebGLCubeProbeRenderer.d.ts +27 -0
- package/src/engine/graphics/sh3/lpv/WebGLCubeProbeRenderer.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/WebGLCubeProbeRenderer.js +158 -0
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts +11 -0
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +127 -0
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts +12 -0
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/probe_volume_to_textures.js +89 -0
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts +90 -0
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +352 -0
- package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts +5 -91
- package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +41 -477
- package/src/engine/graphics/sh3/path_tracer/make_one_vector3.d.ts +1 -0
- package/src/engine/graphics/sh3/path_tracer/make_one_vector3.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/make_one_vector3.js +6 -3
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +38 -62
- package/src/engine/graphics/sh3/path_tracer/random_in_hemisphere.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/random_in_hemisphere.js +7 -1
- package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts +2 -2
- package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples.d.ts +10 -0
- package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples.js +20 -0
- package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples_2d.d.ts +10 -0
- package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples_2d.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/sampling/generate_stratified_samples_2d.js +31 -0
- package/src/engine/graphics/sh3/path_tracer/sampling/make_stratified_sample.d.ts +9 -0
- package/src/engine/graphics/sh3/path_tracer/sampling/make_stratified_sample.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/sampling/make_stratified_sample.js +21 -0
- package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts +3 -0
- package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/texture/SoftwareTextureCache.js +3 -0
- package/src/engine/graphics/sh3/path_tracer/texture/apply_texture_clamping_to_coordinate.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/{apply_texture_clamping_to_coordinate.js → texture/apply_texture_clamping_to_coordinate.js} +2 -2
- package/src/engine/graphics/sh3/path_tracer/texture/sample_material.d.ts +11 -0
- package/src/engine/graphics/sh3/path_tracer/texture/sample_material.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +86 -0
- package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.d.ts +10 -0
- package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/texture/sample_texture.js +55 -0
- package/src/engine/graphics/sh3/path_tracer/vec3_uint8_to_float.js +4 -4
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +145 -185
- package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.d.ts +5 -5
- package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.d.ts.map +1 -1
- package/src/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js +8 -8
- package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.d.ts +13 -0
- package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.d.ts.map +1 -0
- package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.js +54 -0
- package/src/engine/graphics/texture/AttributeDataTexture.d.ts +2 -2
- package/src/engine/graphics/texture/AttributeDataTexture.d.ts.map +1 -1
- package/src/engine/graphics/texture/AttributeDataTexture.js +11 -11
- package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.js +2 -2
- package/src/engine/input/ecs/systems/InputControllerSystem.js +1 -1
- package/src/engine/network/convertPathToURL.d.ts +3 -1
- package/src/engine/network/convertPathToURL.d.ts.map +1 -1
- package/src/engine/network/convertPathToURL.js +68 -51
- package/src/engine/physics/fluid/SliceVisualiser.d.ts.map +1 -1
- package/src/engine/physics/fluid/SliceVisualiser.js +4 -4
- package/src/generation/filtering/numeric/CellFilterCache.d.ts.map +1 -1
- package/src/generation/filtering/numeric/CellFilterCache.js +1 -0
- package/src/view/elements/ColorPickerView.d.ts.map +1 -1
- package/src/view/elements/ColorPickerView.js +7 -7
- package/src/core/binary/float2uint8.d.ts +0 -7
- package/src/core/binary/float2uint8.d.ts.map +0 -1
- package/src/core/binary/uint82float.d.ts +0 -7
- package/src/core/binary/uint82float.d.ts.map +0 -1
- package/src/core/binary/uint82float.spec.d.ts +0 -2
- package/src/core/binary/uint82float.spec.d.ts.map +0 -1
- package/src/core/binary/uint82float.spec.js +0 -7
- package/src/core/collection/array/randomizeArrayElementOrder.d.ts +0 -8
- package/src/core/collection/array/randomizeArrayElementOrder.d.ts.map +0 -1
- package/src/core/collection/array/randomizeArrayElementOrder.js +0 -24
- package/src/core/collection/array/randomizeArrayElementOrder.spec.d.ts +0 -2
- package/src/core/collection/array/randomizeArrayElementOrder.spec.d.ts.map +0 -1
- package/src/core/geom/3d/tetrahedra/compute_circumsphere.d.ts.map +0 -1
- package/src/core/graph/coarsen_graph.d.ts.map +0 -1
- package/src/core/graph/coarsen_graph.spec.d.ts +0 -2
- package/src/core/graph/coarsen_graph.spec.d.ts.map +0 -1
- package/src/core/graph/graph_adjacency_matrix.d.ts +0 -9
- package/src/core/graph/graph_adjacency_matrix.d.ts.map +0 -1
- package/src/core/graph/graph_degree_matrix.d.ts +0 -9
- package/src/core/graph/graph_degree_matrix.d.ts.map +0 -1
- package/src/core/graph/graph_degree_matrix.js +0 -18
- package/src/core/graph/graph_laplacian_matrix.d.ts.map +0 -1
- package/src/core/math/physics/brdf/D_GGX.d.ts.map +0 -1
- package/src/engine/graphics/sh3/LightProbeVolume.d.ts.map +0 -1
- package/src/engine/graphics/sh3/LightProbeVolume.js +0 -609
- package/src/engine/graphics/sh3/path_tracer/apply_texture_clamping_to_coordinate.d.ts.map +0 -1
- package/src/engine/graphics/sh3/visualise_probe.d.ts +0 -12
- package/src/engine/graphics/sh3/visualise_probe.d.ts.map +0 -1
- package/src/engine/graphics/sh3/visualise_probe.js +0 -40
- /package/src/engine/graphics/sh3/path_tracer/{apply_texture_clamping_to_coordinate.d.ts → texture/apply_texture_clamping_to_coordinate.d.ts} +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Assumes that the mesh is compacted
|
|
5
|
+
* @param {AttributeDataTexture} vertices
|
|
6
|
+
* @param {AttributeDataTexture} neighbours
|
|
7
|
+
* @param {TetrahedralMesh} mesh
|
|
8
|
+
*/
|
|
9
|
+
export function tetrahedral_mesh_to_texture(
|
|
10
|
+
vertices,
|
|
11
|
+
neighbours,
|
|
12
|
+
mesh
|
|
13
|
+
) {
|
|
14
|
+
|
|
15
|
+
assert.equal(mesh.isCompacted, true, 'mesh.isCompacted');
|
|
16
|
+
|
|
17
|
+
if (mesh.isCompacted !== true) {
|
|
18
|
+
throw new Error(`mesh is not compacted`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (vertices.spec.itemSize !== 4) {
|
|
22
|
+
throw new Error(`vertices texture spec must have itemSize of 4, instead was ${vertices.spec.itemSize}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (neighbours.spec.itemSize !== 4) {
|
|
26
|
+
throw new Error(`neighbours texture spec must have itemSize of 4, instead was ${neighbours.spec.itemSize}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const tetrahedron_count = mesh.count;
|
|
30
|
+
|
|
31
|
+
vertices.resize(tetrahedron_count);
|
|
32
|
+
neighbours.resize(tetrahedron_count);
|
|
33
|
+
|
|
34
|
+
vertices.build()
|
|
35
|
+
neighbours.build();
|
|
36
|
+
|
|
37
|
+
const vertices_data = vertices.data;
|
|
38
|
+
const neighbours_data = neighbours.data;
|
|
39
|
+
|
|
40
|
+
for (let i = 0; i < tetrahedron_count; i++) {
|
|
41
|
+
|
|
42
|
+
const i4 = i * 4;
|
|
43
|
+
|
|
44
|
+
for (let j = 0; j < 4; j++) {
|
|
45
|
+
vertices_data[i4 + j] = mesh.getVertexIndex(i, j);
|
|
46
|
+
|
|
47
|
+
neighbours_data[i4 + j] = mesh.getNeighbour(i, j);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -3,6 +3,16 @@ export class LightProbeVolume {
|
|
|
3
3
|
__mesh: TetrahedralMesh;
|
|
4
4
|
__probe_data: any[];
|
|
5
5
|
__length: number;
|
|
6
|
+
clear(): void;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @return {TetrahedralMesh}
|
|
10
|
+
*/
|
|
11
|
+
get mesh(): TetrahedralMesh;
|
|
12
|
+
get points(): any[];
|
|
13
|
+
get harmonics(): any[];
|
|
14
|
+
set count(arg: number);
|
|
15
|
+
get count(): number;
|
|
6
16
|
/**
|
|
7
17
|
*
|
|
8
18
|
* @param {number} x
|
|
@@ -23,10 +33,10 @@ export class LightProbeVolume {
|
|
|
23
33
|
build_mesh(): void;
|
|
24
34
|
/**
|
|
25
35
|
* Bake light probes
|
|
26
|
-
* @param {Engine} engine
|
|
27
36
|
* @returns {TaskGroup}
|
|
37
|
+
* @param {EntityComponentDataset} ecd
|
|
28
38
|
*/
|
|
29
|
-
bake(
|
|
39
|
+
bake(ecd: EntityComponentDataset): TaskGroup;
|
|
30
40
|
/**
|
|
31
41
|
*
|
|
32
42
|
* @param {EntityComponentDataset} ecd
|
|
@@ -38,15 +48,16 @@ export class LightProbeVolume {
|
|
|
38
48
|
*
|
|
39
49
|
* @param {EntityComponentDataset} ecd
|
|
40
50
|
* @param {string|number} color CSS color definition
|
|
51
|
+
* @param {number} opacity
|
|
41
52
|
*/
|
|
42
|
-
visualize_mesh({ ecd, color }: EntityComponentDataset): void;
|
|
53
|
+
visualize_mesh({ ecd, color, opacity }: EntityComponentDataset): void;
|
|
43
54
|
/**
|
|
44
55
|
*
|
|
45
|
-
* @param {Engine} engine
|
|
46
56
|
* @returns {TaskGroup}
|
|
57
|
+
* @param {EntityComponentDataset} ecd
|
|
47
58
|
*/
|
|
48
|
-
build(
|
|
59
|
+
build(ecd: EntityComponentDataset): TaskGroup;
|
|
49
60
|
}
|
|
50
|
-
import { TetrahedralMesh } from "
|
|
51
|
-
import TaskGroup from "
|
|
61
|
+
import { TetrahedralMesh } from "../../../../core/geom/3d/tetrahedra/TetrahedralMesh.js";
|
|
62
|
+
import TaskGroup from "../../../../core/process/task/TaskGroup.js";
|
|
52
63
|
//# sourceMappingURL=LightProbeVolume.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LightProbeVolume.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolume.js"],"names":[],"mappings":"AAiJA;IAEQ,mBAAqB;IAErB,wBAAmC;IAEnC,oBAAsB;IAEtB,iBAAiB;IAGrB,cAMC;IAED;;;OAGG;IACH,4BAEC;IAED,oBAEC;IAED,uBAEC;IAMD,uBAEC;IAND,oBAEC;IAMD;;;;;OAKG;IACH,aAJW,MAAM,KACN,MAAM,KACN,MAAM,QAchB;IAED;;;;;OAKG;IACH,mBAJW,MAAM,UACN,MAAM,EAAE,iBACR,MAAM,QAIhB;IAED;;OAEG;IACH,mBAaC;IAGD;;;;OAIG;IACH,mCAHa,SAAS,CA4CrB;IAED;;;;;OAKG;IACH,sEAWC;IAED;;;;;OAKG;IACH,sEAkBC;IAED;;;;OAIG;IACH,oCAHa,SAAS,CAMrB;CACJ;gCA1U+B,wDAAwD;sBAClE,4CAA4C"}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { LineBasicMaterial } from "three";
|
|
2
|
+
import { array_copy } from "../../../../core/collection/array/array_copy.js";
|
|
3
|
+
import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
|
|
4
|
+
import {
|
|
5
|
+
build_tetrahedral_mesh_buffer_geometry
|
|
6
|
+
} from "../../../../core/geom/3d/tetrahedra/build_tetrahedral_mesh_buffer_geometry.js";
|
|
7
|
+
import {
|
|
8
|
+
compute_delaunay_tetrahedral_mesh
|
|
9
|
+
} from "../../../../core/geom/3d/tetrahedra/delaunay/compute_delaunay_tetrahedral_mesh.js";
|
|
10
|
+
import { TetrahedralMesh } from "../../../../core/geom/3d/tetrahedra/TetrahedralMesh.js";
|
|
11
|
+
import TaskGroup from "../../../../core/process/task/TaskGroup.js";
|
|
12
|
+
import { actionTask } from "../../../../core/process/task/util/actionTask.js";
|
|
13
|
+
import { countTask } from "../../../../core/process/task/util/countTask.js";
|
|
14
|
+
import { promiseTask } from "../../../../core/process/task/util/promiseTask.js";
|
|
15
|
+
import Entity from "../../../ecs/Entity.js";
|
|
16
|
+
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
17
|
+
import { DrawMode } from "../../ecs/mesh-v2/DrawMode.js";
|
|
18
|
+
import { ShadedGeometry } from "../../ecs/mesh-v2/ShadedGeometry.js";
|
|
19
|
+
import { ShadedGeometryFlags } from "../../ecs/mesh-v2/ShadedGeometryFlags.js";
|
|
20
|
+
import { visualise_spherical_harmonic_sphere } from "../visualise_spherical_harmonic_sphere.js";
|
|
21
|
+
import { PathTracerProbeRenderer } from "./PathTracerProbeRenderer.js";
|
|
22
|
+
|
|
23
|
+
const TEMP_CONTACT = new SurfacePoint3();
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class Baker {
|
|
27
|
+
constructor() {
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @type {EntityComponentDataset|null}
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
this.__ecd = null;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @type {BVH|null}
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
this.__bvh = null;
|
|
41
|
+
|
|
42
|
+
this.__min_bounce_count = 3;
|
|
43
|
+
this.__max_bounce_count = 100;
|
|
44
|
+
|
|
45
|
+
this._ren = new PathTracerProbeRenderer();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {BVH} bvh
|
|
50
|
+
*/
|
|
51
|
+
set_bvh(bvh) {
|
|
52
|
+
this.__bvh = bvh;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
build_spatial() {
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param {number[]} irradiance RGB irradiance result is written here
|
|
62
|
+
* @param {number} bounce_count number of reflections before this trace
|
|
63
|
+
* @param {number} origin_x
|
|
64
|
+
* @param {number} origin_y
|
|
65
|
+
* @param {number} origin_z
|
|
66
|
+
* @param {number} direction_x
|
|
67
|
+
* @param {number} direction_y
|
|
68
|
+
* @param {number} direction_z
|
|
69
|
+
*/
|
|
70
|
+
trace_ray(irradiance, bounce_count,
|
|
71
|
+
origin_x, origin_y, origin_z,
|
|
72
|
+
direction_x, direction_y, direction_z) {
|
|
73
|
+
|
|
74
|
+
//
|
|
75
|
+
|
|
76
|
+
if (!this.ray_cast(TEMP_CONTACT, origin_x, origin_y, origin_z, direction_x, direction_y, direction_z)) {
|
|
77
|
+
// no hit, assume irradiance is zeroed - black
|
|
78
|
+
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// record irradiance
|
|
83
|
+
|
|
84
|
+
// reflect ray around normal
|
|
85
|
+
// TODO apply BDRF to compute reflected ray
|
|
86
|
+
|
|
87
|
+
if (bounce_count > this.__max_bounce_count) {
|
|
88
|
+
// terminate
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
*
|
|
95
|
+
* @param contact
|
|
96
|
+
* @param origin_x
|
|
97
|
+
* @param origin_y
|
|
98
|
+
* @param origin_z
|
|
99
|
+
* @param direction_x
|
|
100
|
+
* @param direction_y
|
|
101
|
+
* @param direction_z
|
|
102
|
+
* @returns {boolean}
|
|
103
|
+
*/
|
|
104
|
+
ray_cast(contact,
|
|
105
|
+
origin_x, origin_y, origin_z,
|
|
106
|
+
direction_x, direction_y, direction_z
|
|
107
|
+
) {
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
prepare_scene() {
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
*
|
|
117
|
+
* @param {number[]} position
|
|
118
|
+
* @param {number} position_offset
|
|
119
|
+
* @param {number[]} output
|
|
120
|
+
* @param {number} output_offset
|
|
121
|
+
*/
|
|
122
|
+
bake_sh3_cube(
|
|
123
|
+
position, position_offset,
|
|
124
|
+
output, output_offset
|
|
125
|
+
) {
|
|
126
|
+
|
|
127
|
+
this._ren.bake(position, position_offset, output, output_offset);
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
*
|
|
133
|
+
*/
|
|
134
|
+
async prepare(ecd) {
|
|
135
|
+
|
|
136
|
+
this._ren.build_scene(ecd);
|
|
137
|
+
|
|
138
|
+
await this._ren.bake_start();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
finish() {
|
|
142
|
+
this._ren.bake_end();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export class LightProbeVolume {
|
|
147
|
+
constructor() {
|
|
148
|
+
this.__positions = [];
|
|
149
|
+
|
|
150
|
+
this.__mesh = new TetrahedralMesh();
|
|
151
|
+
|
|
152
|
+
this.__probe_data = [];
|
|
153
|
+
|
|
154
|
+
this.__length = 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
clear() {
|
|
158
|
+
this.__positions.splice(0, this.__positions.length);
|
|
159
|
+
this.__probe_data.splice(0, this.__probe_data.length);
|
|
160
|
+
this.__mesh.clear();
|
|
161
|
+
|
|
162
|
+
this.__length = 0;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
*
|
|
167
|
+
* @return {TetrahedralMesh}
|
|
168
|
+
*/
|
|
169
|
+
get mesh() {
|
|
170
|
+
return this.__mesh;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
get points() {
|
|
174
|
+
return this.__positions;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
get harmonics() {
|
|
178
|
+
return this.__probe_data;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
get count() {
|
|
182
|
+
return this.__length;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
set count(v) {
|
|
186
|
+
this.__length = v;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
*
|
|
191
|
+
* @param {number} x
|
|
192
|
+
* @param {number} y
|
|
193
|
+
* @param {number} z
|
|
194
|
+
*/
|
|
195
|
+
add_point(x, y, z) {
|
|
196
|
+
const i = this.__length;
|
|
197
|
+
|
|
198
|
+
this.__positions[i * 3] = x;
|
|
199
|
+
this.__positions[i * 3 + 1] = y;
|
|
200
|
+
this.__positions[i * 3 + 2] = z;
|
|
201
|
+
|
|
202
|
+
for (let j = 0; j < 9 * 3; j++) {
|
|
203
|
+
this.__probe_data[i * 9 * 3 + j] = 1; // fill with white
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
this.__length++;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
*
|
|
211
|
+
* @param {number} index
|
|
212
|
+
* @param {number[]} source
|
|
213
|
+
* @param {number} source_offset
|
|
214
|
+
*/
|
|
215
|
+
white_probe(index, source, source_offset) {
|
|
216
|
+
array_copy(source, source_offset, this.__probe_data, index * 9 * 3, 9 * 3);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Build tetrahedral mesh
|
|
221
|
+
*/
|
|
222
|
+
build_mesh() {
|
|
223
|
+
|
|
224
|
+
const t0 = performance.now();
|
|
225
|
+
compute_delaunay_tetrahedral_mesh(this.__mesh, this.__positions, this.__length);
|
|
226
|
+
|
|
227
|
+
const t1 = performance.now();
|
|
228
|
+
|
|
229
|
+
// optional step to improve memory utilization
|
|
230
|
+
this.__mesh.compact();
|
|
231
|
+
|
|
232
|
+
const t2 = performance.now();
|
|
233
|
+
|
|
234
|
+
console.log(`Tetrahedral mesh (${this.__length} points, ${this.__mesh.size()} tets) build took ${t2 - t0}ms`);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Bake light probes
|
|
240
|
+
* @returns {TaskGroup}
|
|
241
|
+
* @param {EntityComponentDataset} ecd
|
|
242
|
+
*/
|
|
243
|
+
bake(ecd) {
|
|
244
|
+
const baker = new Baker();
|
|
245
|
+
// baker.set_bvh(entityManager.getSystem(ShadedGeometrySystem).__bvh_binary);
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
const tPrepare = promiseTask(new Promise(async (resolve, reject) => {
|
|
249
|
+
await baker.prepare(ecd);
|
|
250
|
+
|
|
251
|
+
resolve();
|
|
252
|
+
}), 'Prepare');
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
const probe_count = this.__length;
|
|
256
|
+
const tBake = countTask(0, probe_count, (i) => {
|
|
257
|
+
|
|
258
|
+
baker.bake_sh3_cube(
|
|
259
|
+
this.__positions, i * 3,
|
|
260
|
+
this.__probe_data, i * 9 * 3
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
});
|
|
264
|
+
tBake.estimatedDuration = probe_count;
|
|
265
|
+
|
|
266
|
+
tBake.promise().then(() => {
|
|
267
|
+
|
|
268
|
+
const duration = tBake.__executedCpuTime;
|
|
269
|
+
|
|
270
|
+
console.log(`Baked ${probe_count} probes in ${duration}ms, ~${(duration / probe_count).toFixed(2)}ms per probe`);
|
|
271
|
+
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
const tFinish = actionTask(() => {
|
|
275
|
+
baker.finish();
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
tFinish.addDependency(tBake);
|
|
279
|
+
tBake.addDependency(tPrepare);
|
|
280
|
+
|
|
281
|
+
return new TaskGroup([
|
|
282
|
+
tPrepare, tBake, tFinish
|
|
283
|
+
], "LightProbeVolume Bake");
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
*
|
|
288
|
+
* @param {EntityComponentDataset} ecd
|
|
289
|
+
* @param {number} size
|
|
290
|
+
* @param {boolean} shadow
|
|
291
|
+
*/
|
|
292
|
+
visualize_probes({ ecd, size = 0.2, shadow = false }) {
|
|
293
|
+
for (let i = 0; i < this.__length; i++) {
|
|
294
|
+
visualise_spherical_harmonic_sphere({
|
|
295
|
+
size,
|
|
296
|
+
position: this.__positions,
|
|
297
|
+
position_offset: i * 3,
|
|
298
|
+
sh: this.__probe_data,
|
|
299
|
+
sh_offset: i * 3 * 9,
|
|
300
|
+
shadow: shadow
|
|
301
|
+
}).build(ecd);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
*
|
|
307
|
+
* @param {EntityComponentDataset} ecd
|
|
308
|
+
* @param {string|number} color CSS color definition
|
|
309
|
+
* @param {number} opacity
|
|
310
|
+
*/
|
|
311
|
+
visualize_mesh({ ecd, color = '#FF00FF', opacity = 0.35 }) {
|
|
312
|
+
|
|
313
|
+
const geometry = build_tetrahedral_mesh_buffer_geometry(this.__mesh, this.__positions);
|
|
314
|
+
|
|
315
|
+
const sg = ShadedGeometry.from(geometry, new LineBasicMaterial({
|
|
316
|
+
color: color,
|
|
317
|
+
transparent: true,
|
|
318
|
+
opacity,
|
|
319
|
+
depthWrite: false
|
|
320
|
+
}), DrawMode.LineSegments);
|
|
321
|
+
|
|
322
|
+
sg.clearFlag(ShadedGeometryFlags.CastShadow);
|
|
323
|
+
sg.clearFlag(ShadedGeometryFlags.ReceiveShadow);
|
|
324
|
+
|
|
325
|
+
new Entity()
|
|
326
|
+
.add(sg)
|
|
327
|
+
.add(new Transform())
|
|
328
|
+
.build(ecd);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
*
|
|
333
|
+
* @returns {TaskGroup}
|
|
334
|
+
* @param {EntityComponentDataset} ecd
|
|
335
|
+
*/
|
|
336
|
+
build(ecd) {
|
|
337
|
+
this.build_mesh();
|
|
338
|
+
return this.bake(ecd);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class LightProbeVolumeSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
2
|
+
klass: typeof LightProbeVolume;
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param buffer
|
|
6
|
+
* @param {LightProbeVolume} value
|
|
7
|
+
*/
|
|
8
|
+
serialize(buffer: any, value: LightProbeVolume): void;
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param buffer
|
|
12
|
+
* @param {LightProbeVolume} value
|
|
13
|
+
*/
|
|
14
|
+
deserialize(buffer: any, value: LightProbeVolume): void;
|
|
15
|
+
}
|
|
16
|
+
import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
17
|
+
import { LightProbeVolume } from "./LightProbeVolume.js";
|
|
18
|
+
//# sourceMappingURL=LightProbeVolumeSerializationAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LightProbeVolumeSerializationAdapter.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.js"],"names":[],"mappings":"AAGA;IAEI,+BAAwB;IAGxB;;;;OAIG;IACH,8BAFW,gBAAgB,QAY1B;IAED;;;;OAIG;IACH,gCAFW,gBAAgB,QAc1B;CACJ;gDA3C+C,gEAAgE;iCAC/E,uBAAuB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BinaryClassSerializationAdapter } from "../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
2
|
+
import { LightProbeVolume } from "./LightProbeVolume.js";
|
|
3
|
+
|
|
4
|
+
export class LightProbeVolumeSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
5
|
+
|
|
6
|
+
klass = LightProbeVolume
|
|
7
|
+
version = 0
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param buffer
|
|
12
|
+
* @param {LightProbeVolume} value
|
|
13
|
+
*/
|
|
14
|
+
serialize(buffer, value) {
|
|
15
|
+
const count = value.count;
|
|
16
|
+
|
|
17
|
+
buffer.writeUint32(count);
|
|
18
|
+
// write probe position data
|
|
19
|
+
buffer.writeFloat32Array(value.points, 0, count * 3);
|
|
20
|
+
// probe values
|
|
21
|
+
buffer.writeFloat32Array(value.harmonics, 0, count * 27);
|
|
22
|
+
|
|
23
|
+
value.mesh.serialize(buffer);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param buffer
|
|
29
|
+
* @param {LightProbeVolume} value
|
|
30
|
+
*/
|
|
31
|
+
deserialize(buffer, value) {
|
|
32
|
+
value.clear();
|
|
33
|
+
|
|
34
|
+
const count = buffer.readUint32();
|
|
35
|
+
|
|
36
|
+
value.count = count;
|
|
37
|
+
|
|
38
|
+
buffer.readFloat32Array(value.points, 0, count * 3);
|
|
39
|
+
buffer.readFloat32Array(value.harmonics, 0, count * 27);
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
value.mesh.deserialize(buffer);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export class PathTracerProbeRenderer extends ProbeRenderer {
|
|
2
|
+
tracer: PathTracer;
|
|
3
|
+
sample_count: number;
|
|
4
|
+
random: () => number;
|
|
5
|
+
scene: PathTracedScene;
|
|
6
|
+
bake(position: any, position_offset: any, output: any, output_offset: any): void;
|
|
7
|
+
build_scene(ecd: any): void;
|
|
8
|
+
}
|
|
9
|
+
import { ProbeRenderer } from "./ProbeRenderer.js";
|
|
10
|
+
import { PathTracer } from "../path_tracer/PathTracer.js";
|
|
11
|
+
import { PathTracedScene } from "../path_tracer/PathTracedScene.js";
|
|
12
|
+
//# sourceMappingURL=PathTracerProbeRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PathTracerProbeRenderer.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js"],"names":[],"mappings":"AAuBA;IACI,mBAA0B;IAC1B,qBAAmB;IACnB,qBAAyB;IAEzB,uBAA6B;IAE7B,iFA2CC;IASD,4BAsCC;CACJ;8BA3G6B,oBAAoB;2BADvB,8BAA8B;gCADzB,mCAAmC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { array_copy } from "../../../../core/collection/array/array_copy.js";
|
|
2
|
+
import { sh3_basis_at } from "../../../../core/geom/3d/sphere/harmonics/sh3_basis_at.js";
|
|
3
|
+
import {
|
|
4
|
+
sh3_dering_optimize_positive
|
|
5
|
+
} from "../../../../core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js";
|
|
6
|
+
import { randomPointOnSphere } from "../../../../core/geom/random/randomPointOnSphere.js";
|
|
7
|
+
import { seededRandom } from "../../../../core/math/random/seededRandom.js";
|
|
8
|
+
import { Transform } from "../../../ecs/transform/Transform.js";
|
|
9
|
+
import { Light } from "../../ecs/light/Light.js";
|
|
10
|
+
import { LightType } from "../../ecs/light/LightType.js";
|
|
11
|
+
import { ShadedGeometry } from "../../ecs/mesh-v2/ShadedGeometry.js";
|
|
12
|
+
import { DirectionalLight } from "../../render/forward_plus/model/DirectionalLight.js";
|
|
13
|
+
import { PathTracedScene } from "../path_tracer/PathTracedScene.js";
|
|
14
|
+
import { PathTracer } from "../path_tracer/PathTracer.js";
|
|
15
|
+
import { ProbeRenderer } from "./ProbeRenderer.js";
|
|
16
|
+
|
|
17
|
+
const __shared_buffer = new ArrayBuffer((27 + 9) * 8);
|
|
18
|
+
const sh_basis = new Float64Array(__shared_buffer, 0, 9);
|
|
19
|
+
const coefficients = new Float64Array(__shared_buffer, 9 * 8, 27);
|
|
20
|
+
|
|
21
|
+
const ray = new Float32Array(6);
|
|
22
|
+
const sampled_irradiance = new Float32Array(3);
|
|
23
|
+
|
|
24
|
+
export class PathTracerProbeRenderer extends ProbeRenderer {
|
|
25
|
+
tracer = new PathTracer();
|
|
26
|
+
sample_count = 256;
|
|
27
|
+
random = seededRandom(0);
|
|
28
|
+
|
|
29
|
+
scene = new PathTracedScene()
|
|
30
|
+
|
|
31
|
+
bake(position, position_offset, output, output_offset) {
|
|
32
|
+
|
|
33
|
+
const tracer = this.tracer;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
array_copy(position, position_offset, ray, 0, 3);
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
coefficients.fill(0);
|
|
40
|
+
|
|
41
|
+
for (let i = 0; i < this.sample_count; i++) {
|
|
42
|
+
|
|
43
|
+
randomPointOnSphere(this.random, ray, 3);
|
|
44
|
+
|
|
45
|
+
tracer.path_trace(sampled_irradiance, ray, Infinity, 1, 7, this.random, this.scene);
|
|
46
|
+
|
|
47
|
+
sh3_basis_at(ray[3], ray[4], ray[5], sh_basis);
|
|
48
|
+
|
|
49
|
+
// accumulate
|
|
50
|
+
for (let j = 0; j < 9; j++) {
|
|
51
|
+
|
|
52
|
+
const j3 = j * 3;
|
|
53
|
+
|
|
54
|
+
const projected_coefficient = sh_basis[j];
|
|
55
|
+
|
|
56
|
+
coefficients[j3] += projected_coefficient * sampled_irradiance[0];
|
|
57
|
+
coefficients[j3 + 1] += projected_coefficient * sampled_irradiance[1];
|
|
58
|
+
coefficients[j3 + 2] += projected_coefficient * sampled_irradiance[2];
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Area of a unit sphere is (4*PI)
|
|
64
|
+
|
|
65
|
+
const normalization_weight = (4 * Math.PI) / this.sample_count;
|
|
66
|
+
|
|
67
|
+
for (let i = 0; i < 27; i++) {
|
|
68
|
+
coefficients[i] *= normalization_weight;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
sh3_dering_optimize_positive(coefficients, 0, coefficients, 0, 3);
|
|
72
|
+
|
|
73
|
+
array_copy(coefficients, 0, output, output_offset, 27);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
bake_end() {
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
bake_start() {
|
|
80
|
+
return this.scene.build();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
build_scene(ecd) {
|
|
84
|
+
|
|
85
|
+
const scene = this.scene;
|
|
86
|
+
|
|
87
|
+
ecd.traverseEntities([ShadedGeometry, Transform],
|
|
88
|
+
/**
|
|
89
|
+
*
|
|
90
|
+
* @param {ShadedGeometry} sg
|
|
91
|
+
* @param {Transform} transform
|
|
92
|
+
*/
|
|
93
|
+
(sg, transform) => {
|
|
94
|
+
|
|
95
|
+
scene.addMesh(sg.geometry, sg.material, transform.matrix)
|
|
96
|
+
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
ecd.traverseEntities([Light, Transform],
|
|
101
|
+
/**
|
|
102
|
+
*
|
|
103
|
+
* @param {Light} light
|
|
104
|
+
* @param {Transform} transform
|
|
105
|
+
*/
|
|
106
|
+
(light, transform) => {
|
|
107
|
+
|
|
108
|
+
if (light.type.getValue() === LightType.DIRECTION) {
|
|
109
|
+
|
|
110
|
+
const l = new DirectionalLight();
|
|
111
|
+
|
|
112
|
+
l.color.copy(light.color);
|
|
113
|
+
l.direction.copy(transform.forward);
|
|
114
|
+
l.intensity.copy(light.intensity);
|
|
115
|
+
|
|
116
|
+
scene.addLight(l);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @abstract
|
|
3
|
+
*/
|
|
4
|
+
export class ProbeRenderer {
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {EntityComponentDataset} ecd
|
|
8
|
+
* @abstract
|
|
9
|
+
*/
|
|
10
|
+
build_scene(ecd: EntityComponentDataset): void;
|
|
11
|
+
/**
|
|
12
|
+
* @abstract
|
|
13
|
+
*/
|
|
14
|
+
bake_start(): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* @abstract
|
|
17
|
+
*/
|
|
18
|
+
bake_end(): void;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param {number[]} position
|
|
22
|
+
* @param {number} position_offset
|
|
23
|
+
* @param {number[]} output
|
|
24
|
+
* @param {number} output_offset
|
|
25
|
+
* @abstract
|
|
26
|
+
*/
|
|
27
|
+
bake(position: number[], position_offset: number, output: number[], output_offset: number): void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ProbeRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProbeRenderer.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/lpv/ProbeRenderer.js"],"names":[],"mappings":"AAAA;;GAEG;AACH;IACI;;;;OAIG;IACH,+CACC;IAED;;OAEG;IACH,4BACC;IAED;;OAEG;IACH,iBACC;IAED;;;;;;;OAOG;IACH,eANW,MAAM,EAAE,mBACR,MAAM,UACN,MAAM,EAAE,iBACR,MAAM,QAIhB;CACJ"}
|