@woosh/meep-engine 2.109.0 → 2.109.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/meep.cjs +150 -199
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +150 -199
- package/package.json +1 -1
- package/src/core/binary/BitSet.d.ts +6 -0
- package/src/core/binary/BitSet.d.ts.map +1 -1
- package/src/core/binary/BitSet.js +14 -42
- package/src/core/binary/align_32.d.ts +7 -0
- package/src/core/binary/align_32.d.ts.map +1 -0
- package/src/core/binary/align_32.js +8 -0
- package/src/core/binary/align_32.spec.d.ts +2 -0
- package/src/core/binary/align_32.spec.d.ts.map +1 -0
- package/src/core/binary/align_32.spec.js +11 -0
- package/src/core/binary/align_4.js +2 -1
- package/src/core/binary/ctz32.d.ts.map +1 -1
- package/src/core/binary/ctz32.js +12 -11
- package/src/core/binary/lsb_32.d.ts +9 -0
- package/src/core/binary/lsb_32.d.ts.map +1 -0
- package/src/core/binary/lsb_32.js +12 -0
- package/src/core/binary/msb_32.d.ts +2 -0
- package/src/core/binary/msb_32.d.ts.map +1 -0
- package/src/core/binary/msb_32.js +20 -0
- package/src/core/binary/msb_lut_de_bruijn.d.ts +7 -0
- package/src/core/binary/msb_lut_de_bruijn.d.ts.map +1 -0
- package/src/core/binary/msb_lut_de_bruijn.js +9 -0
- package/src/core/binary/reinterpret_int32_as_float32.d.ts +7 -0
- package/src/core/binary/reinterpret_int32_as_float32.d.ts.map +1 -0
- package/src/core/binary/reinterpret_int32_as_float32.js +14 -0
- package/src/core/binary/reverse_bits_uint32.d.ts +8 -0
- package/src/core/binary/reverse_bits_uint32.d.ts.map +1 -0
- package/src/core/binary/reverse_bits_uint32.js +17 -0
- package/src/core/binary/reverse_bits_uint32.spec.d.ts +2 -0
- package/src/core/binary/reverse_bits_uint32.spec.d.ts.map +1 -0
- package/src/core/binary/reverse_bits_uint32.spec.js +18 -0
- package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/BVH.js +13 -18
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.js +3 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +6 -7
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.js +4 -0
- package/src/core/bvh2/bvh3/query/backtracking/bvh_backtracking_query_leaves_ray.d.ts +16 -0
- package/src/core/bvh2/bvh3/query/backtracking/bvh_backtracking_query_leaves_ray.d.ts.map +1 -0
- package/src/core/bvh2/bvh3/query/backtracking/bvh_backtracking_query_leaves_ray.js +130 -0
- package/src/core/bvh2/bvh3/query/cache/BVH_QUERY_CACHE_SIZE.d.ts +2 -0
- package/src/core/bvh2/bvh3/query/cache/BVH_QUERY_CACHE_SIZE.d.ts.map +1 -0
- package/src/core/bvh2/bvh3/query/cache/BVH_QUERY_CACHE_SIZE.js +1 -0
- package/src/core/bvh2/bvh3/query/cache/bvh_query_cache_hash_v3.d.ts +9 -0
- package/src/core/bvh2/bvh3/query/cache/bvh_query_cache_hash_v3.d.ts.map +1 -0
- package/src/core/bvh2/bvh3/query/cache/bvh_query_cache_hash_v3.js +31 -0
- package/src/core/collection/array/array_quick_sort_by_lookup_map.d.ts +9 -0
- package/src/core/collection/array/array_quick_sort_by_lookup_map.d.ts.map +1 -0
- package/src/core/collection/array/array_quick_sort_by_lookup_map.js +79 -0
- package/src/core/collection/array/array_quick_sort_by_lookup_uint.d.ts +8 -0
- package/src/core/collection/array/array_quick_sort_by_lookup_uint.d.ts.map +1 -0
- package/src/core/collection/array/{array_quick_sort_by_lookup.js → array_quick_sort_by_lookup_uint.js} +1 -1
- package/src/core/collection/array/array_shuffle.js +1 -1
- package/src/core/collection/array/array_swap_one.d.ts.map +1 -1
- package/src/core/collection/array/array_swap_one.js +6 -0
- package/src/core/events/signal/Signal.d.ts.map +1 -1
- package/src/core/events/signal/Signal.js +10 -10
- package/src/core/geom/2d/compute_triangle_area_2d.d.ts.map +1 -1
- package/src/core/geom/2d/compute_triangle_area_2d.js +5 -3
- package/src/core/geom/3d/Ray3.d.ts +6 -0
- package/src/core/geom/3d/Ray3.d.ts.map +1 -1
- package/src/core/geom/3d/Ray3.js +24 -0
- package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.d.ts +16 -0
- package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.d.ts.map +1 -0
- package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.js +29 -0
- package/src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.d.ts +2 -2
- package/src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.js +6 -6
- package/src/core/geom/3d/aabb/aabb3_overlaps_ray_segment.d.ts +11 -0
- package/src/core/geom/3d/aabb/aabb3_overlaps_ray_segment.d.ts.map +1 -0
- package/src/core/geom/3d/aabb/aabb3_overlaps_ray_segment.js +61 -0
- package/src/core/geom/3d/eulerAnglesFromMatrix.d.ts +2 -2
- package/src/core/geom/3d/eulerAnglesFromMatrix.d.ts.map +1 -1
- package/src/core/geom/3d/eulerAnglesFromMatrix.js +28 -25
- package/src/core/geom/3d/morton/v3_morton_encode_bounded.d.ts +2 -2
- package/src/core/geom/3d/morton/v3_morton_encode_bounded.d.ts.map +1 -1
- package/src/core/geom/3d/morton/v3_morton_encode_bounded.js +1 -1
- package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts +2 -2
- package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts.map +1 -1
- package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js +1 -1
- package/src/core/geom/3d/ray/ray3_shift_origin_along_direction.js +2 -2
- package/src/core/geom/3d/sphere/harmonics/sh3_convolve_with_cosine_kernel.js +2 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_vector_accumulate.d.ts +12 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_vector_accumulate.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_vector_accumulate.js +40 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_vector_accumulate.spec.d.ts +2 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_vector_accumulate.spec.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_vector_accumulate.spec.js +27 -0
- package/src/core/geom/3d/sphere/sphere_intersects_ray.js +1 -1
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.js +24 -188
- package/src/core/geom/3d/tetrahedra/triangle/prototype.js +1 -1
- package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.d.ts +11 -0
- package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.js +42 -0
- package/src/core/geom/3d/topology/samples/sampleFloodFill.js +2 -2
- package/src/core/geom/3d/topology/tm_face_area.js +2 -2
- package/src/core/geom/3d/triangle/{computeTriangleSurfaceArea.d.ts → compute_triangle_area_3d.d.ts} +2 -2
- package/src/core/geom/3d/triangle/compute_triangle_area_3d.d.ts.map +1 -0
- package/src/core/geom/3d/triangle/{computeTriangleSurfaceArea.js → compute_triangle_area_3d.js} +2 -4
- package/src/core/geom/Quaternion.d.ts.map +1 -1
- package/src/core/geom/Quaternion.js +13 -102
- package/src/core/geom/Quaternion.spec.js +2 -2
- package/src/core/geom/Vector1.d.ts.map +1 -1
- package/src/core/geom/Vector1.js +14 -6
- package/src/core/geom/vec/vector_copy.d.ts +10 -0
- package/src/core/geom/vec/vector_copy.d.ts.map +1 -0
- package/src/core/geom/vec/vector_copy.js +13 -0
- package/src/core/{math/vector_nd_dot.d.ts → geom/vec/vector_dot.d.ts} +2 -2
- package/src/core/geom/vec/vector_dot.d.ts.map +1 -0
- package/src/core/{math/vector_nd_dot.js → geom/vec/vector_dot.js} +1 -1
- package/src/core/{math/vector_nd_normalize.d.ts → geom/vec/vector_normalize.d.ts} +2 -2
- package/src/core/geom/vec/vector_normalize.d.ts.map +1 -0
- package/src/core/{math/vector_nd_normalize.js → geom/vec/vector_normalize.js} +1 -1
- package/src/core/geom/vec/vector_normalize.spec.d.ts +2 -0
- package/src/core/geom/vec/vector_normalize.spec.d.ts.map +1 -0
- package/src/core/{math/vector_nd_normalize.spec.js → geom/vec/vector_normalize.spec.js} +3 -3
- package/src/core/geom/vec/vector_scale_array.d.ts +11 -0
- package/src/core/geom/vec/vector_scale_array.d.ts.map +1 -0
- package/src/core/geom/vec/vector_scale_array.js +31 -0
- package/src/core/geom/vec3/v3_array_displace_in_direction.d.ts +14 -0
- package/src/core/geom/vec3/v3_array_displace_in_direction.d.ts.map +1 -0
- package/src/core/geom/vec3/{v3_shift_along_direction.js → v3_array_displace_in_direction.js} +1 -1
- package/src/core/geom/vec3/v3_displace_in_direction.d.ts +7 -7
- package/src/core/geom/vec3/v3_displace_in_direction.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_displace_in_direction.js +20 -17
- package/src/core/geom/vec3/v3_displace_in_direction.spec.d.ts +2 -0
- package/src/core/geom/vec3/v3_displace_in_direction.spec.d.ts.map +1 -0
- package/src/core/geom/vec3/v3_displace_in_direction.spec.js +80 -0
- package/src/core/geom/vec3/v3_dot_array_array.js +2 -0
- package/src/core/geom/vec4/v4_length.d.ts +10 -0
- package/src/core/geom/vec4/v4_length.d.ts.map +1 -0
- package/src/core/geom/vec4/v4_length.js +13 -0
- package/src/core/geom/vec4/v4_length_sqr.js +2 -1
- package/src/core/graph/eigen/matrix_eigenvalues_in_place.spec.js +31 -1
- package/src/core/math/FLT_EPSILON_64.d.ts +6 -0
- package/src/core/math/FLT_EPSILON_64.d.ts.map +1 -0
- package/src/core/math/FLT_EPSILON_64.js +5 -0
- package/src/core/math/gaussian.d.ts +2 -2
- package/src/core/math/gaussian.js +2 -2
- package/src/core/math/linalg/README.md +1 -0
- package/src/core/math/linalg/lu_factor_linear_system.d.ts +13 -0
- package/src/core/math/linalg/lu_factor_linear_system.d.ts.map +1 -0
- package/src/core/math/linalg/lu_factor_linear_system.js +112 -0
- package/src/core/math/linalg/lu_solve_linear_system.d.ts +14 -0
- package/src/core/math/linalg/lu_solve_linear_system.d.ts.map +1 -0
- package/src/core/math/linalg/lu_solve_linear_system.js +51 -0
- package/src/core/math/linalg/solve_linear_system.d.ts +14 -0
- package/src/core/math/linalg/solve_linear_system.d.ts.map +1 -0
- package/src/core/math/linalg/solve_linear_system.js +52 -0
- package/src/core/math/linalg/solve_linear_system.spec.d.ts +2 -0
- package/src/core/math/linalg/solve_linear_system.spec.d.ts.map +1 -0
- package/src/core/math/linalg/solve_linear_system.spec.js +70 -0
- package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts +10 -0
- package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts.map +1 -0
- package/src/core/math/linalg/solve_linear_system_GEPP_2x2.js +91 -0
- package/src/core/math/solveQuadratic.d.ts.map +1 -1
- package/src/core/math/solveQuadratic.js +2 -0
- package/src/core/math/statistics/gaussian_amplitude.d.ts +8 -0
- package/src/core/math/statistics/gaussian_amplitude.d.ts.map +1 -0
- package/src/core/math/statistics/gaussian_amplitude.js +13 -0
- package/src/core/math/statistics/halton_sequence.js +3 -3
- package/src/core/math/statistics/halton_sequence.spec.js +18 -0
- package/src/core/math/statistics/hammersley_sequence.d.ts +9 -0
- package/src/core/math/statistics/hammersley_sequence.d.ts.map +1 -0
- package/src/core/math/statistics/hammersley_sequence.js +25 -0
- package/src/core/math/statistics/hammersley_sequence_2d.d.ts +9 -0
- package/src/core/math/statistics/hammersley_sequence_2d.d.ts.map +1 -0
- package/src/core/math/statistics/hammersley_sequence_2d.js +17 -0
- package/src/core/math/statistics/radical_inverse_VdC_base_2.d.ts +8 -0
- package/src/core/math/statistics/radical_inverse_VdC_base_2.d.ts.map +1 -0
- package/src/core/math/statistics/radical_inverse_VdC_base_2.js +15 -0
- package/src/core/math/statistics/radical_inverse_VdC_base_2.spec.d.ts +2 -0
- package/src/core/math/statistics/radical_inverse_VdC_base_2.spec.d.ts.map +1 -0
- package/src/core/math/statistics/radical_inverse_VdC_base_2.spec.js +9 -0
- package/src/core/model/node-graph/node/NodeInstance.d.ts.map +1 -1
- package/src/core/model/node-graph/node/NodeInstance.js +44 -12
- package/src/core/model/node-graph/node/NodeInstance.spec.d.ts +2 -0
- package/src/core/model/node-graph/node/NodeInstance.spec.d.ts.map +1 -0
- package/src/core/model/node-graph/node/NodeInstance.spec.js +82 -0
- package/src/core/model/node-graph/node/NodeInstancePortReference.d.ts.map +1 -1
- package/src/core/model/node-graph/node/NodeInstancePortReference.js +9 -0
- package/src/core/model/node-graph/node/NodeInstancePortReference.spec.js +20 -0
- package/src/core/model/node-graph/node/Port.d.ts.map +1 -1
- package/src/core/model/node-graph/node/Port.js +5 -12
- package/src/core/model/node-graph/node/PortDirection.d.ts.map +1 -1
- package/src/core/model/node-graph/node/PortDirection.js +7 -1
- package/src/engine/asset/CORS/CrossOriginConfig.d.ts.map +1 -1
- package/src/engine/asset/CORS/CrossOriginConfig.js +6 -4
- package/src/engine/graphics/geometry/computeMeshSurfaceArea.js +2 -2
- package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.js +33 -3
- package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +9 -7
- package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_INFERNO.d.ts +6 -0
- package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_INFERNO.d.ts.map +1 -0
- package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_INFERNO.js +18 -0
- package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_TURBO.d.ts +6 -0
- package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_TURBO.d.ts.map +1 -0
- package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_TURBO.js +266 -0
- package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_VIRIDIS.d.ts +7 -0
- package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_VIRIDIS.d.ts.map +1 -0
- package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_VIRIDIS.js +19 -0
- package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +9 -9
- package/src/engine/graphics/sh3/fromCubeRenderTarget.d.ts.map +1 -1
- package/src/engine/graphics/sh3/fromCubeRenderTarget.js +14 -17
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +0 -2
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +7 -29
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +52 -164
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts +13 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +63 -0
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +1 -0
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +33 -16
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
- package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +4 -29
- package/src/engine/graphics/sh3/lpv/{LightProbeVolumeSerializationAdapter.d.ts → serialization/LightProbeVolumeSerializationAdapter.d.ts} +2 -2
- package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/{LightProbeVolumeSerializationAdapter.js → serialization/LightProbeVolumeSerializationAdapter.js} +2 -2
- package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts +13 -0
- package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/sh3_bake_depth.js +71 -0
- package/src/engine/graphics/sh3/lpv/worker/lpv_build_worker.d.ts +2 -0
- package/src/engine/graphics/sh3/lpv/worker/lpv_build_worker.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lpv/worker/lpv_build_worker.js +38 -0
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts +1 -7
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +58 -147
- package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.d.ts +13 -9
- package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +74 -54
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts +23 -5
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +211 -59
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts +15 -0
- package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.js +46 -0
- package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts +14 -0
- package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.js +43 -0
- package/src/engine/graphics/sh3/path_tracer/geometry/compute_triangle_group_aabb3.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/{compute_triangle_group_aabb3.js → geometry/compute_triangle_group_aabb3.js} +2 -2
- package/src/engine/graphics/sh3/path_tracer/geometry/construct_ray_hit_from_geometry.d.ts +12 -0
- package/src/engine/graphics/sh3/path_tracer/geometry/construct_ray_hit_from_geometry.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/geometry/construct_ray_hit_from_geometry.js +72 -0
- package/src/engine/graphics/sh3/path_tracer/geometry/sample_triangle_attribute.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/geometry/sort_triangles_by_distance_to_point.d.ts +13 -0
- package/src/engine/graphics/sh3/path_tracer/geometry/sort_triangles_by_distance_to_point.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/geometry/sort_triangles_by_distance_to_point.js +48 -0
- package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.d.ts +1 -0
- package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.js +4 -0
- package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.d.ts +1 -0
- package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.js +8 -5
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +24 -18
- package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.d.ts +2 -2
- package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/sampling/getBiasedNormalSample.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/{getBiasedNormalSample.js → sampling/getBiasedNormalSample.js} +1 -1
- package/src/engine/graphics/sh3/path_tracer/sampling/random_in_hemisphere.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/{random_in_hemisphere.js → sampling/random_in_hemisphere.js} +1 -1
- package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts +12 -0
- package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.js +46 -0
- package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +2 -2
- package/src/engine/graphics/sh3/path_tracer/three_object_to_path_traced_scene.d.ts +7 -0
- package/src/engine/graphics/sh3/path_tracer/three_object_to_path_traced_scene.d.ts.map +1 -0
- package/src/engine/graphics/sh3/path_tracer/three_object_to_path_traced_scene.js +69 -0
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +45 -7
- package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.d.ts +11 -1
- package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.d.ts.map +1 -1
- package/src/engine/graphics/sh3/visualise_spherical_harmonic_sphere.js +33 -16
- package/src/engine/graphics/texture/formatToChannelCount.d.ts.map +1 -1
- package/src/engine/graphics/texture/formatToChannelCount.js +14 -1
- package/src/engine/graphics/three/three_object_replace_materials.d.ts +7 -0
- package/src/engine/graphics/three/three_object_replace_materials.d.ts.map +1 -0
- package/src/engine/graphics/three/three_object_replace_materials.js +13 -0
- package/src/engine/sound/material/detector/terrain/TerrainSoundMaterialSurfaceDetector.d.ts.map +1 -1
- package/src/engine/sound/material/detector/terrain/TerrainSoundMaterialSurfaceDetector.js +6 -6
- package/src/core/collection/array/array_quick_sort_by_lookup.d.ts +0 -8
- package/src/core/collection/array/array_quick_sort_by_lookup.d.ts.map +0 -1
- package/src/core/geom/3d/triangle/computeTriangleSurfaceArea.d.ts.map +0 -1
- package/src/core/geom/vec3/v3_shift_along_direction.d.ts +0 -14
- package/src/core/geom/vec3/v3_shift_along_direction.d.ts.map +0 -1
- package/src/core/math/vector_nd_dot.d.ts.map +0 -1
- package/src/core/math/vector_nd_normalize.d.ts.map +0 -1
- package/src/core/math/vector_nd_normalize.spec.d.ts +0 -2
- package/src/core/math/vector_nd_normalize.spec.d.ts.map +0 -1
- package/src/engine/graphics/filter/FlipArrayViaCanvas.d.ts +0 -2
- package/src/engine/graphics/filter/FlipArrayViaCanvas.d.ts.map +0 -1
- package/src/engine/graphics/filter/FlipArrayViaCanvas.js +0 -13
- package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/getBiasedNormalSample.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/random_in_hemisphere.d.ts.map +0 -1
- package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts.map +0 -1
- /package/src/engine/graphics/sh3/path_tracer/{compute_triangle_group_aabb3.d.ts → geometry/compute_triangle_group_aabb3.d.ts} +0 -0
- /package/src/engine/graphics/sh3/path_tracer/{sample_triangle_attribute.d.ts → geometry/sample_triangle_attribute.d.ts} +0 -0
- /package/src/engine/graphics/sh3/path_tracer/{sample_triangle_attribute.js → geometry/sample_triangle_attribute.js} +0 -0
- /package/src/engine/graphics/sh3/path_tracer/{getBiasedNormalSample.d.ts → sampling/getBiasedNormalSample.d.ts} +0 -0
- /package/src/engine/graphics/sh3/path_tracer/{random_in_hemisphere.d.ts → sampling/random_in_hemisphere.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lpv_build_worker.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/lpv/worker/lpv_build_worker.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BinaryBuffer } from "../../../../../core/binary/BinaryBuffer.js";
|
|
2
|
+
import { EntityComponentDataset } from "../../../../ecs/EntityComponentDataset.js";
|
|
3
|
+
import { LightProbeVolume } from "../LightProbeVolume.js";
|
|
4
|
+
import { LightProbeVolumeSerializationAdapter } from "../serialization/LightProbeVolumeSerializationAdapter.js";
|
|
5
|
+
|
|
6
|
+
const adapter = new LightProbeVolumeSerializationAdapter();
|
|
7
|
+
const volume = new LightProbeVolume();
|
|
8
|
+
|
|
9
|
+
const scene = new EntityComponentDataset();
|
|
10
|
+
|
|
11
|
+
self.Contex = {
|
|
12
|
+
volume,
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param {ArrayBuffer} data
|
|
17
|
+
*/
|
|
18
|
+
load_scene(data){
|
|
19
|
+
const buffer = BinaryBuffer.fromArrayBuffer(data);
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
serialize() {
|
|
26
|
+
const buffer = new BinaryBuffer();
|
|
27
|
+
|
|
28
|
+
adapter.serialize(buffer, volume);
|
|
29
|
+
|
|
30
|
+
buffer.trim();
|
|
31
|
+
|
|
32
|
+
return buffer.data;
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
reset() {
|
|
36
|
+
volume.clear()
|
|
37
|
+
}
|
|
38
|
+
};
|
|
@@ -4,12 +4,6 @@ export class BufferedGeometryBVH {
|
|
|
4
4
|
* @param {AABB3|number[]} out
|
|
5
5
|
*/
|
|
6
6
|
getBounds(out: AABB3 | number[]): void;
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @type {BVH}
|
|
10
|
-
* @private
|
|
11
|
-
*/
|
|
12
|
-
private __bvh;
|
|
13
7
|
/**
|
|
14
8
|
*
|
|
15
9
|
* @type {THREE.BufferGeometry|null}
|
|
@@ -40,7 +34,7 @@ export class BufferedGeometryBVH {
|
|
|
40
34
|
*/
|
|
41
35
|
build(geometry: THREE.BufferGeometry): void;
|
|
42
36
|
/**
|
|
43
|
-
*
|
|
37
|
+
* NOTE: raycast is performed in local coordinate space
|
|
44
38
|
* @param {number[]} output
|
|
45
39
|
* @param {number[]} ray
|
|
46
40
|
* @param {number} min_distance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BufferedGeometryBVH.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BufferedGeometryBVH.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js"],"names":[],"mappings":"AA2BA;IAkBI;;;OAGG;IACH,eAFW,KAAK,GAAC,MAAM,EAAE,QAIxB;IAIG;;;;OAIG;IACH,mBAAsB;IAEtB;;;;OAIG;IACH,yBAA4B;IAE5B;;;;OAIG;IACH,6BAAgC;IAGhC;;;;OAIG;IACH,yBAAyB;IAG7B;;;OAGG;IACH,gBAFW,MAAM,cAAc,QAsC9B;IAGD;;;;;;;OAOG;IACH,gBANW,MAAM,EAAE,OACR,MAAM,EAAE,gBACR,MAAM,gBACN,MAAM,GACJ,MAAM,CA+FlB;;CACJ;sBAlOqB,wCAAwC"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
|
|
1
|
+
import { BVH, ELEMENT_WORD_COUNT } from "../../../../core/bvh2/bvh3/BVH.js";
|
|
3
2
|
import { ebvh_build_for_geometry_morton } from "../../../../core/bvh2/bvh3/ebvh_build_for_geometry_morton.js";
|
|
4
|
-
import {
|
|
3
|
+
import { bvh_query_leaves_ray } from "../../../../core/bvh2/bvh3/query/bvh_query_leaves_ray.js";
|
|
5
4
|
import { array_copy } from "../../../../core/collection/array/array_copy.js";
|
|
6
|
-
import { array_quick_sort_by_comparator } from "../../../../core/collection/array/array_quick_sort_by_comparator.js";
|
|
7
5
|
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
6
|
+
import {
|
|
7
|
+
aabb3_unsigned_distance_sqr_to_point
|
|
8
|
+
} from "../../../../core/geom/3d/aabb/aabb3_unsigned_distance_sqr_to_point.js";
|
|
8
9
|
|
|
9
10
|
import {
|
|
10
11
|
computeTriangleRayIntersectionBarycentricGeometry
|
|
11
12
|
} from "../../../../core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.js";
|
|
12
|
-
import
|
|
13
|
+
import Vector4 from "../../../../core/geom/Vector4.js";
|
|
14
|
+
import { computeBoundingSphereFromVertexData } from "../../geometry/computeBoundingSphereFromVertexData.js";
|
|
15
|
+
import { construct_ray_hit_from_geometry } from "./geometry/construct_ray_hit_from_geometry.js";
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
*
|
|
@@ -22,124 +25,6 @@ const scratch_uint32_array = new Uint32Array(4096);
|
|
|
22
25
|
*/
|
|
23
26
|
const v3_scratch_0 = [];
|
|
24
27
|
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
* @param {number[]} triangles
|
|
28
|
-
* @param {number} offset
|
|
29
|
-
* @param {number} count
|
|
30
|
-
* @param {number} point_x
|
|
31
|
-
* @param {number} point_y
|
|
32
|
-
* @param {number} point_z
|
|
33
|
-
* @param morton_codes
|
|
34
|
-
* @param bounds
|
|
35
|
-
*/
|
|
36
|
-
function sort_triangles_by_distance_to_point(
|
|
37
|
-
triangles, offset, count,
|
|
38
|
-
morton_codes, bounds,
|
|
39
|
-
point_x, point_y, point_z,
|
|
40
|
-
) {
|
|
41
|
-
const bounds_x0 = bounds.x0;
|
|
42
|
-
const bounds_y0 = bounds.y0;
|
|
43
|
-
const bounds_z0 = bounds.z0;
|
|
44
|
-
|
|
45
|
-
const bounds_scale_x = bounds.getExtentsX() / 1023;
|
|
46
|
-
const bounds_scale_y = bounds.getExtentsY() / 1023;
|
|
47
|
-
const bounds_scale_z = bounds.getExtentsZ() / 1023;
|
|
48
|
-
|
|
49
|
-
array_quick_sort_by_comparator(scratch_uint32_array, (a, b) => {
|
|
50
|
-
|
|
51
|
-
const morton_a = morton_codes[a];
|
|
52
|
-
const morton_b = morton_codes[b];
|
|
53
|
-
|
|
54
|
-
const ax = bounds_x0 + bounds_scale_x * split_by_3(morton_a);
|
|
55
|
-
const ay = bounds_y0 + bounds_scale_y * split_by_3(morton_a >>> 1);
|
|
56
|
-
const az = bounds_z0 + bounds_scale_z * split_by_3(morton_a >>> 2);
|
|
57
|
-
|
|
58
|
-
const bx = bounds_x0 + bounds_scale_x * split_by_3(morton_b);
|
|
59
|
-
const by = bounds_y0 + bounds_scale_y * split_by_3(morton_b >>> 1);
|
|
60
|
-
const bz = bounds_z0 + bounds_scale_z * split_by_3(morton_b >>> 2);
|
|
61
|
-
|
|
62
|
-
const delta_a = v3_distance_sqr(ax, ay, az, point_x, point_y, point_z);
|
|
63
|
-
const delta_b = v3_distance_sqr(bx, by, bz, point_x, point_y, point_z);
|
|
64
|
-
|
|
65
|
-
return delta_b - delta_a;
|
|
66
|
-
}, undefined, offset, count - 1);
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
*
|
|
72
|
-
* @param {number[]} output
|
|
73
|
-
* @param {number[]} indices
|
|
74
|
-
* @param {number[]} positions
|
|
75
|
-
* @param {number} face_index
|
|
76
|
-
* @param {number} t
|
|
77
|
-
* @param {number} u
|
|
78
|
-
* @param {number} v
|
|
79
|
-
*/
|
|
80
|
-
function construct_ray_hit(
|
|
81
|
-
output,
|
|
82
|
-
indices, positions,
|
|
83
|
-
face_index,
|
|
84
|
-
t, u, v
|
|
85
|
-
) {
|
|
86
|
-
|
|
87
|
-
const index_offset = face_index * 3;
|
|
88
|
-
|
|
89
|
-
const a = indices[index_offset];
|
|
90
|
-
const b = indices[index_offset + 1];
|
|
91
|
-
const c = indices[index_offset + 2];
|
|
92
|
-
|
|
93
|
-
const a_address = a * 3;
|
|
94
|
-
const b_address = b * 3;
|
|
95
|
-
const c_address = c * 3;
|
|
96
|
-
|
|
97
|
-
const ax = positions[a_address];
|
|
98
|
-
const ay = positions[a_address + 1];
|
|
99
|
-
const az = positions[a_address + 2];
|
|
100
|
-
|
|
101
|
-
const bx = positions[b_address];
|
|
102
|
-
const by = positions[b_address + 1];
|
|
103
|
-
const bz = positions[b_address + 2];
|
|
104
|
-
|
|
105
|
-
const cx = positions[c_address];
|
|
106
|
-
const cy = positions[c_address + 1];
|
|
107
|
-
const cz = positions[c_address + 2];
|
|
108
|
-
|
|
109
|
-
// normal
|
|
110
|
-
|
|
111
|
-
// edge1 = a - b
|
|
112
|
-
const edge1_x = bx - ax;
|
|
113
|
-
const edge1_y = by - ay;
|
|
114
|
-
const edge1_z = bz - az;
|
|
115
|
-
|
|
116
|
-
// edge2 = c - a
|
|
117
|
-
const edge2_x = cx - ax;
|
|
118
|
-
const edge2_y = cy - ay;
|
|
119
|
-
const edge2_z = cz - az;
|
|
120
|
-
|
|
121
|
-
// compute position of intersection point
|
|
122
|
-
output[0] = ax + edge1_x * u + edge2_x * v;
|
|
123
|
-
output[1] = ay + edge1_y * u + edge2_y * v;
|
|
124
|
-
output[2] = az + edge1_z * u + edge2_z * v;
|
|
125
|
-
|
|
126
|
-
// Compute triangle normal
|
|
127
|
-
|
|
128
|
-
// normal = edge1 x edge2
|
|
129
|
-
const normal_x = edge1_y * edge2_z - edge1_z * edge2_y;
|
|
130
|
-
const normal_y = edge1_z * edge2_x - edge1_x * edge2_z;
|
|
131
|
-
const normal_z = edge1_x * edge2_y - edge1_y * edge2_x
|
|
132
|
-
|
|
133
|
-
output[3] = normal_x;
|
|
134
|
-
output[4] = normal_y;
|
|
135
|
-
output[5] = normal_z;
|
|
136
|
-
|
|
137
|
-
output[6] = t;
|
|
138
|
-
output[7] = u;
|
|
139
|
-
output[8] = v;
|
|
140
|
-
output[9] = face_index;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
28
|
export class BufferedGeometryBVH {
|
|
144
29
|
/**
|
|
145
30
|
* @type {Uint32Array}
|
|
@@ -148,6 +33,16 @@ export class BufferedGeometryBVH {
|
|
|
148
33
|
|
|
149
34
|
#bounds = new AABB3()
|
|
150
35
|
|
|
36
|
+
#bounds_sphere = new Float32Array(4);
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @type {BVH}
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
#bvh = new BVH();
|
|
45
|
+
|
|
151
46
|
/**
|
|
152
47
|
*
|
|
153
48
|
* @param {AABB3|number[]} out
|
|
@@ -157,12 +52,6 @@ export class BufferedGeometryBVH {
|
|
|
157
52
|
}
|
|
158
53
|
|
|
159
54
|
constructor() {
|
|
160
|
-
/**
|
|
161
|
-
*
|
|
162
|
-
* @type {BVH}
|
|
163
|
-
* @private
|
|
164
|
-
*/
|
|
165
|
-
this.__bvh = new BVH();
|
|
166
55
|
|
|
167
56
|
/**
|
|
168
57
|
*
|
|
@@ -215,7 +104,7 @@ export class BufferedGeometryBVH {
|
|
|
215
104
|
|
|
216
105
|
this.#morton_codes = new Uint32Array(this.__triangle_count);
|
|
217
106
|
|
|
218
|
-
const bvh = this
|
|
107
|
+
const bvh = this.#bvh;
|
|
219
108
|
|
|
220
109
|
ebvh_build_for_geometry_morton(
|
|
221
110
|
bvh,
|
|
@@ -229,11 +118,16 @@ export class BufferedGeometryBVH {
|
|
|
229
118
|
|
|
230
119
|
// remove any extra unused space
|
|
231
120
|
bvh.trim();
|
|
121
|
+
|
|
122
|
+
const r = new Vector4();
|
|
123
|
+
computeBoundingSphereFromVertexData(array_positions, r);
|
|
124
|
+
|
|
125
|
+
r.toArray(this.#bounds_sphere);
|
|
232
126
|
}
|
|
233
127
|
|
|
234
128
|
|
|
235
129
|
/**
|
|
236
|
-
*
|
|
130
|
+
* NOTE: raycast is performed in local coordinate space
|
|
237
131
|
* @param {number[]} output
|
|
238
132
|
* @param {number[]} ray
|
|
239
133
|
* @param {number} min_distance
|
|
@@ -242,6 +136,7 @@ export class BufferedGeometryBVH {
|
|
|
242
136
|
*/
|
|
243
137
|
raycast(output, ray, min_distance, max_distance) {
|
|
244
138
|
|
|
139
|
+
|
|
245
140
|
const indices = this.__geometry_index;
|
|
246
141
|
const positions = this.__geometry_positions;
|
|
247
142
|
|
|
@@ -253,10 +148,9 @@ export class BufferedGeometryBVH {
|
|
|
253
148
|
const direction_y = ray[4];
|
|
254
149
|
const direction_z = ray[5];
|
|
255
150
|
|
|
256
|
-
const bvh = this
|
|
151
|
+
const bvh = this.#bvh;
|
|
257
152
|
|
|
258
|
-
|
|
259
|
-
const count = bvh_query_user_data_ray(
|
|
153
|
+
const count = bvh_query_leaves_ray(
|
|
260
154
|
bvh, bvh.root,
|
|
261
155
|
scratch_uint32_array, 0,
|
|
262
156
|
origin_x, origin_y, origin_z,
|
|
@@ -268,22 +162,37 @@ export class BufferedGeometryBVH {
|
|
|
268
162
|
return -1;
|
|
269
163
|
}
|
|
270
164
|
|
|
271
|
-
|
|
165
|
+
|
|
166
|
+
let nearest_hit_distance = max_distance;
|
|
272
167
|
|
|
273
168
|
let best_index = -1;
|
|
274
169
|
let best_u = 0;
|
|
275
170
|
let best_v = 0;
|
|
171
|
+
let best_node = -1;
|
|
276
172
|
|
|
277
|
-
// sort triangles by distance to origin
|
|
278
|
-
if (count > 64) {
|
|
279
|
-
// encode
|
|
280
|
-
sort_triangles_by_distance_to_point(scratch_uint32_array, 0, count, this.#morton_codes, this.#bounds, origin_x, origin_y, origin_z);
|
|
281
|
-
}
|
|
282
173
|
|
|
174
|
+
/*
|
|
175
|
+
For performance, we bind data directly to avoid extra copies required to read out AABB
|
|
176
|
+
*/
|
|
177
|
+
const float32 = bvh.__data_float32;
|
|
283
178
|
|
|
284
179
|
// check triangles found via BVH
|
|
285
180
|
for (let i = 0; i < count; i++) {
|
|
286
|
-
const
|
|
181
|
+
const node = scratch_uint32_array[i];
|
|
182
|
+
|
|
183
|
+
const node_address = node * ELEMENT_WORD_COUNT;
|
|
184
|
+
|
|
185
|
+
if (aabb3_unsigned_distance_sqr_to_point(
|
|
186
|
+
float32[node_address], float32[node_address + 1], float32[node_address + 2],
|
|
187
|
+
float32[node_address + 3], float32[node_address + 4], float32[node_address + 5],
|
|
188
|
+
|
|
189
|
+
origin_x, origin_y, origin_z
|
|
190
|
+
) > nearest_hit_distance * nearest_hit_distance) {
|
|
191
|
+
// bounds of the mesh are too far
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const triangle_index = bvh.node_get_user_data(node);
|
|
287
196
|
|
|
288
197
|
const intersection_found = computeTriangleRayIntersectionBarycentricGeometry(
|
|
289
198
|
v3_scratch_0,
|
|
@@ -299,22 +208,24 @@ export class BufferedGeometryBVH {
|
|
|
299
208
|
|
|
300
209
|
const t = v3_scratch_0[0];
|
|
301
210
|
|
|
302
|
-
if (t <
|
|
303
|
-
|
|
211
|
+
if (t < nearest_hit_distance && t > min_distance) {
|
|
212
|
+
nearest_hit_distance = t;
|
|
304
213
|
|
|
305
214
|
best_index = triangle_index;
|
|
306
215
|
best_u = v3_scratch_0[1];
|
|
307
216
|
best_v = v3_scratch_0[2];
|
|
217
|
+
|
|
218
|
+
best_node = node;
|
|
308
219
|
}
|
|
309
220
|
}
|
|
310
221
|
|
|
311
|
-
if (
|
|
222
|
+
if (nearest_hit_distance === max_distance) {
|
|
312
223
|
// no hit
|
|
313
224
|
return -1;
|
|
314
225
|
}
|
|
315
226
|
|
|
316
|
-
|
|
227
|
+
construct_ray_hit_from_geometry(output, indices, positions, best_index, nearest_hit_distance, best_u, best_v);
|
|
317
228
|
|
|
318
|
-
return
|
|
229
|
+
return nearest_hit_distance;
|
|
319
230
|
}
|
|
320
|
-
}
|
|
231
|
+
}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
export class PathTracedMesh {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @type {number}
|
|
5
|
+
*/
|
|
6
|
+
id: number;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @type {AABB3}
|
|
10
|
+
*/
|
|
2
11
|
aabb: AABB3;
|
|
3
12
|
/**
|
|
4
13
|
*
|
|
5
14
|
* @type {BufferedGeometryBVH|null}
|
|
6
15
|
*/
|
|
7
|
-
|
|
16
|
+
bvh: BufferedGeometryBVH | null;
|
|
8
17
|
/**
|
|
9
18
|
*
|
|
10
19
|
* @type {THREE.BufferGeometry|null}
|
|
@@ -15,14 +24,8 @@ export class PathTracedMesh {
|
|
|
15
24
|
* @type {StandardMaterial|null}
|
|
16
25
|
*/
|
|
17
26
|
material: StandardMaterial | null;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
__local_scale_inverse: number;
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
* @type {number}
|
|
24
|
-
*/
|
|
25
|
-
id: number;
|
|
27
|
+
build_tight_bounds(): void;
|
|
28
|
+
update_bounds(): void;
|
|
26
29
|
set transform(arg: Float32Array);
|
|
27
30
|
get transform(): Float32Array;
|
|
28
31
|
/**
|
|
@@ -34,6 +37,7 @@ export class PathTracedMesh {
|
|
|
34
37
|
* @returns {number} distance along the ray to contact
|
|
35
38
|
*/
|
|
36
39
|
hit(out: number[], ray: number[], min_distance: number, max_distance: number): number;
|
|
40
|
+
#private;
|
|
37
41
|
}
|
|
38
42
|
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
39
43
|
//# sourceMappingURL=PathTracedMesh.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathTracedMesh.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/PathTracedMesh.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PathTracedMesh.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/PathTracedMesh.js"],"names":[],"mappings":"AAmBA;IACI;;;OAGG;IACH,IAFU,MAAM,CAEO;IAEvB;;;OAGG;IACH,MAFU,KAAK,CAEI;IAEnB;;;OAGG;IACH,KAFU,sBAAoB,IAAI,CAEvB;IAGX;;;OAGG;IACH,UAFU,MAAM,cAAc,GAAC,IAAI,CAEnB;IAEhB;;;OAGG;IACH,UAFU,mBAAiB,IAAI,CAEf;IAKhB,2BAqBC;IAED,sBAGC;IAED,iCAQC;IAED,8BAEC;IAED;;;;;;;OAOG;IACH,SANW,MAAM,EAAE,OACR,MAAM,EAAE,gBACR,MAAM,gBACN,MAAM,GACJ,MAAM,CAmDlB;;CACJ;sBAxJqB,wCAAwC"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { mat4 } from "gl-matrix";
|
|
2
2
|
import { array_copy } from "../../../../core/collection/array/array_copy.js";
|
|
3
3
|
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
4
|
+
import { aabb3_from_v3_array_transformed } from "../../../../core/geom/3d/aabb/aabb3_from_v3_array_transformed.js";
|
|
5
|
+
import { decompose_matrix_4_array } from "../../../../core/geom/3d/decompose_matrix_4_array.js";
|
|
6
|
+
import { allocate_m4 } from "../../../../core/geom/3d/mat4/allocate_m4.js";
|
|
4
7
|
import { ray3_array_apply_matrix4 } from "../../../../core/geom/3d/ray/ray3_array_apply_matrix4.js";
|
|
5
8
|
import { ray3_shift_origin_along_direction } from "../../../../core/geom/3d/ray/ray3_shift_origin_along_direction.js";
|
|
9
|
+
import Quaternion from "../../../../core/geom/Quaternion.js";
|
|
10
|
+
import { v3_array_displace_in_direction } from "../../../../core/geom/vec3/v3_array_displace_in_direction.js";
|
|
6
11
|
import { v3_distance } from "../../../../core/geom/vec3/v3_distance.js";
|
|
7
12
|
import { v3_matrix4_multiply } from "../../../../core/geom/vec3/v3_matrix4_multiply.js";
|
|
8
|
-
import
|
|
13
|
+
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
9
14
|
import { ray_hit_apply_transform } from "./ray_hit_apply_transform.js";
|
|
10
15
|
|
|
11
16
|
const local_ray = new Float32Array(6);
|
|
@@ -13,61 +18,80 @@ const scratch_v3 = new Float32Array(3);
|
|
|
13
18
|
let mesh_id_counter = 0;
|
|
14
19
|
|
|
15
20
|
export class PathTracedMesh {
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @type {number}
|
|
24
|
+
*/
|
|
25
|
+
id = mesh_id_counter++;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @type {AABB3}
|
|
30
|
+
*/
|
|
16
31
|
aabb = new AABB3();
|
|
17
32
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
this.geo_bvh = null;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
* @type {THREE.BufferGeometry|null}
|
|
29
|
-
*/
|
|
30
|
-
this.geometry = null;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
* @type {StandardMaterial|null}
|
|
35
|
-
*/
|
|
36
|
-
this.material = null;
|
|
37
|
-
|
|
38
|
-
const buffer = new ArrayBuffer(16 * 2 * 4);
|
|
39
|
-
|
|
40
|
-
this.__transform_inverse = new Float32Array(buffer, 0, 16);
|
|
41
|
-
this.__transform = new Float32Array(buffer, 16 * 4, 16);
|
|
42
|
-
this.__local_scale_inverse = 1;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
* @type {number}
|
|
47
|
-
*/
|
|
48
|
-
this.id = mesh_id_counter++;
|
|
49
|
-
}
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @type {BufferedGeometryBVH|null}
|
|
36
|
+
*/
|
|
37
|
+
bvh = null;
|
|
50
38
|
|
|
51
|
-
set transform(m) {
|
|
52
|
-
array_copy(m, 0, this.__transform, 0, 16);
|
|
53
|
-
mat4.invert(this.__transform_inverse, m);
|
|
54
39
|
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @type {THREE.BufferGeometry|null}
|
|
43
|
+
*/
|
|
44
|
+
geometry = null;
|
|
57
45
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @type {StandardMaterial|null}
|
|
49
|
+
*/
|
|
50
|
+
material = null;
|
|
51
|
+
|
|
52
|
+
#transform = allocate_m4();
|
|
53
|
+
#transform_inverse = allocate_m4();
|
|
54
|
+
|
|
55
|
+
build_tight_bounds() {
|
|
56
|
+
const position = new Vector3();
|
|
57
|
+
const rotation = new Quaternion();
|
|
58
|
+
const scale = new Vector3();
|
|
59
|
+
|
|
60
|
+
decompose_matrix_4_array(this.#transform, position, rotation, scale);
|
|
61
|
+
|
|
62
|
+
if (rotation.roughlyEquals(Quaternion.identity)) {
|
|
63
|
+
// no rotation component, can safely scale/translate geometry bounds to get tight fit
|
|
64
|
+
this.update_bounds();
|
|
65
|
+
|
|
66
|
+
} else {
|
|
67
|
+
|
|
68
|
+
const position_attribute = this.geometry.getAttribute('position');
|
|
69
|
+
const position_array = position_attribute.array;
|
|
70
|
+
aabb3_from_v3_array_transformed(
|
|
71
|
+
this.aabb,
|
|
72
|
+
position_array, position_array.length,
|
|
73
|
+
this.#transform
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
update_bounds() {
|
|
79
|
+
this.bvh.getBounds(this.aabb);
|
|
80
|
+
this.aabb.applyMatrix4(this.#transform);
|
|
81
|
+
}
|
|
61
82
|
|
|
62
|
-
|
|
83
|
+
set transform(m) {
|
|
84
|
+
array_copy(m, 0, this.#transform, 0, 16);
|
|
85
|
+
|
|
86
|
+
mat4.invert(this.#transform_inverse, m);
|
|
63
87
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
88
|
+
if (this.bvh !== null) {
|
|
89
|
+
this.update_bounds();
|
|
90
|
+
}
|
|
67
91
|
}
|
|
68
92
|
|
|
69
93
|
get transform() {
|
|
70
|
-
return this
|
|
94
|
+
return this.#transform;
|
|
71
95
|
}
|
|
72
96
|
|
|
73
97
|
/**
|
|
@@ -80,8 +104,7 @@ export class PathTracedMesh {
|
|
|
80
104
|
*/
|
|
81
105
|
hit(out, ray, min_distance, max_distance) {
|
|
82
106
|
//transform ray
|
|
83
|
-
const m4 = this
|
|
84
|
-
|
|
107
|
+
const m4 = this.#transform_inverse;
|
|
85
108
|
|
|
86
109
|
// shift ray forward by "min distance"
|
|
87
110
|
ray3_shift_origin_along_direction(local_ray, 0, ray, 0, min_distance);
|
|
@@ -94,7 +117,7 @@ export class PathTracedMesh {
|
|
|
94
117
|
|
|
95
118
|
if (max_distance !== Infinity) {
|
|
96
119
|
// compute position of point at max_distance along the ray
|
|
97
|
-
|
|
120
|
+
v3_array_displace_in_direction(
|
|
98
121
|
scratch_v3, 0,
|
|
99
122
|
ray[0], ray[1], ray[2],
|
|
100
123
|
ray[3], ray[4], ray[5],
|
|
@@ -111,11 +134,11 @@ export class PathTracedMesh {
|
|
|
111
134
|
);
|
|
112
135
|
}
|
|
113
136
|
|
|
114
|
-
let distance_to_hit = this.
|
|
137
|
+
let distance_to_hit = this.bvh.raycast(out, local_ray, 0, max_distance_local);
|
|
115
138
|
|
|
116
139
|
if (distance_to_hit >= 0) {
|
|
117
140
|
// transform output
|
|
118
|
-
ray_hit_apply_transform(out, out, this
|
|
141
|
+
ray_hit_apply_transform(out, out, this.#transform);
|
|
119
142
|
|
|
120
143
|
out[10] = this.id;
|
|
121
144
|
|
|
@@ -124,9 +147,6 @@ export class PathTracedMesh {
|
|
|
124
147
|
out[0], out[1], out[2]
|
|
125
148
|
);
|
|
126
149
|
|
|
127
|
-
if (distance_to_hit > max_distance) {
|
|
128
|
-
return -1;
|
|
129
|
-
}
|
|
130
150
|
}
|
|
131
151
|
|
|
132
152
|
|
|
@@ -40,11 +40,29 @@ export class PathTracedScene {
|
|
|
40
40
|
addLight(light: AbstractLight): void;
|
|
41
41
|
/**
|
|
42
42
|
*
|
|
43
|
-
* @param {
|
|
43
|
+
* @param {PathTracedMesh} mesh
|
|
44
|
+
* @returns {boolean}
|
|
45
|
+
*/
|
|
46
|
+
hasMesh(mesh: PathTracedMesh): boolean;
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @param {PathTracedMesh} mesh
|
|
50
|
+
* @returns {boolean}
|
|
51
|
+
*/
|
|
52
|
+
addMesh(mesh: PathTracedMesh): boolean;
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @param {PathTracedMesh} mesh
|
|
56
|
+
* @returns {boolean}
|
|
57
|
+
*/
|
|
58
|
+
removeMesh(mesh: PathTracedMesh): boolean;
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param {THREE.BufferGeometry} geometry
|
|
44
62
|
* @param {THREE.Material} material
|
|
45
63
|
* @param {mat4|number[]} transform
|
|
46
64
|
*/
|
|
47
|
-
|
|
65
|
+
createMesh(geometry: THREE.BufferGeometry, material: THREE.Material, transform: mat4 | number[]): void;
|
|
48
66
|
/**
|
|
49
67
|
*
|
|
50
68
|
* @param {number[]} out [color_r, color_g, color_b, normal_x, normal_y, normal_z]
|
|
@@ -54,12 +72,12 @@ export class PathTracedScene {
|
|
|
54
72
|
/**
|
|
55
73
|
*
|
|
56
74
|
* @param {number[]} out
|
|
57
|
-
* @param {number[]} ray
|
|
75
|
+
* @param {number[]|Ray3} ray
|
|
58
76
|
* @param {number} min_distance
|
|
59
77
|
* @param {number} max_distance
|
|
60
|
-
* @return {number}
|
|
78
|
+
* @return {number} distance to contact, or -1 if no contact found
|
|
61
79
|
*/
|
|
62
|
-
trace(out: number[], ray: number[], min_distance: number, max_distance: number): number;
|
|
80
|
+
trace(out: number[], ray: number[] | Ray3, min_distance: number, max_distance: number): number;
|
|
63
81
|
/**
|
|
64
82
|
*
|
|
65
83
|
* @param {number[]} out
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathTracedScene.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/PathTracedScene.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PathTracedScene.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/PathTracedScene.js"],"names":[],"mappings":"AAgDA;IAGI;;;OAGG;IACH,eAFU,GAAG,CAEa;IAG1B;;;OAGG;IACH,QAFU,IAAI,MAAM,EAAE,cAAc,CAAC,CAElB;IAEnB;;;OAGG;IACH,UAFU,aAAa,EAAE,CAEX;IAEd;;;OAGG;IACH,WAFU,IAAI,MAAM,cAAc,EAAE,mBAAmB,CAAC,CAElC;IAmBtB;;;;OAIG;IACH,6BAA6C;IAiF7C,iBAOC;IAED,uBAEC;IAED;;;;OAIG;IACH,uBAHW,MAAM,cAAc,GACnB,mBAAmB,CAmB9B;IAED;;;OAGG;IACH,gBAFW,aAAa,QAMvB;IAED;;;;OAIG;IACH,cAHW,cAAc,GACZ,OAAO,CAInB;IAED;;;;OAIG;IACH,cAHW,cAAc,GACZ,OAAO,CAiCnB;IAED;;;;OAIG;IACH,iBAHW,cAAc,GACZ,OAAO,CAgBnB;IAED;;;;;OAKG;IACH,qBAJW,MAAM,cAAc,YACpB,MAAM,QAAQ,aACd,OAAK,MAAM,EAAE,QAavB;IAED;;;;OAIG;IACH,qBAHW,MAAM,EAAE,OACR,MAAM,EAAE,QAyBlB;IAED;;;;;;;OAOG;IACH,WANW,MAAM,EAAE,OACR,MAAM,EAAE,OAAK,gBACb,MAAM,gBACN,MAAM,GACL,MAAM,CAkEjB;IAED;;;;;;OAMG;IACH,uBALW,MAAM,EAAE,cACR,MAAM,aACN,MAAM,EAAE,oBACR,MAAM,QAIhB;IAED;;;;;;;OAOG;IACH,mBANW,MAAM,EAAE,cACR,MAAM,OACN,MAAM,EAAE,eACR,MAAM,GACJ,OAAO,CAmEnB;;CACJ;oBArfkD,mCAAmC;+BAoBvD,qBAAqB;8BAJtB,kDAAkD;oCAC5C,0BAA0B"}
|