@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
|
@@ -1,33 +1,51 @@
|
|
|
1
1
|
import { assert } from "../../../../core/assert.js";
|
|
2
|
-
import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
|
|
3
|
-
import {
|
|
2
|
+
import { BVH, ELEMENT_WORD_COUNT, NULL_NODE } from "../../../../core/bvh2/bvh3/BVH.js";
|
|
3
|
+
import { ebvh_build_hierarchy } from "../../../../core/bvh2/bvh3/ebvh_build_hierarchy.js";
|
|
4
4
|
import { bvh_query_leaves_ray } from "../../../../core/bvh2/bvh3/query/bvh_query_leaves_ray.js";
|
|
5
5
|
import { Cache } from "../../../../core/cache/Cache.js";
|
|
6
6
|
import { array_copy } from "../../../../core/collection/array/array_copy.js";
|
|
7
|
+
import { array_quick_sort_by_lookup_map } from "../../../../core/collection/array/array_quick_sort_by_lookup_map.js";
|
|
7
8
|
import { strictEquals } from "../../../../core/function/strictEquals.js";
|
|
8
|
-
import {
|
|
9
|
+
import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
|
|
9
10
|
import {
|
|
10
11
|
aabb3_unsigned_distance_sqr_to_point
|
|
11
12
|
} from "../../../../core/geom/3d/aabb/aabb3_unsigned_distance_sqr_to_point.js";
|
|
13
|
+
import { v3_morton_encode_bounded } from "../../../../core/geom/3d/morton/v3_morton_encode_bounded.js";
|
|
12
14
|
import { ray3_array_compose } from "../../../../core/geom/3d/ray/ray3_array_compose.js";
|
|
13
15
|
import { v3_dot } from "../../../../core/geom/vec3/v3_dot.js";
|
|
16
|
+
import { max2 } from "../../../../core/math/max2.js";
|
|
14
17
|
import { compute_geometry_polycount } from "../../geometry/compute_geometry_polycount.js";
|
|
15
18
|
import { AbstractLight } from "../../render/forward_plus/model/AbstractLight.js";
|
|
16
|
-
import { ensureGeometryBoundingBox } from "../../util/ensureGeometryBoundingBox.js";
|
|
17
19
|
import { BufferedGeometryBVH } from "./BufferedGeometryBVH.js";
|
|
18
20
|
import { make_vector3 } from "./make_one_vector3.js";
|
|
19
21
|
import { MaterialConverter } from "./material/MaterialConverter.js";
|
|
20
22
|
import { PathTracedMesh } from "./PathTracedMesh.js";
|
|
21
23
|
import { sample_material } from "./texture/sample_material.js";
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @type {number[]|Uint32Array}
|
|
28
|
+
*/
|
|
29
|
+
const scratch_uint32_array = new Uint32Array(4096);
|
|
30
|
+
|
|
24
31
|
const _ray_1 = [];
|
|
25
|
-
const tmp_0 =
|
|
32
|
+
const tmp_0 = new Float64Array(11);
|
|
26
33
|
const null_output = [];
|
|
27
34
|
|
|
28
35
|
const DEFAULT_CONVERTER = new MaterialConverter();
|
|
29
36
|
|
|
30
37
|
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param {Uint32Array} result
|
|
41
|
+
* @param {number} result_offset
|
|
42
|
+
* @param {number} count
|
|
43
|
+
* @param {BVH} bvh
|
|
44
|
+
*/
|
|
45
|
+
function bvh_build_query_cache(result, result_offset, count, bvh) {
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
31
49
|
export class PathTracedScene {
|
|
32
50
|
|
|
33
51
|
|
|
@@ -37,6 +55,7 @@ export class PathTracedScene {
|
|
|
37
55
|
*/
|
|
38
56
|
bvh_top_level = new BVH();
|
|
39
57
|
|
|
58
|
+
|
|
40
59
|
/**
|
|
41
60
|
*
|
|
42
61
|
* @type {Map<number, PathTracedMesh>}
|
|
@@ -55,6 +74,13 @@ export class PathTracedScene {
|
|
|
55
74
|
*/
|
|
56
75
|
geo_cache = new Map();
|
|
57
76
|
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* @type {Map<PathTracedMesh, number>}
|
|
80
|
+
*/
|
|
81
|
+
#mesh_bvh_nodes = new Map();
|
|
82
|
+
|
|
83
|
+
|
|
58
84
|
/**
|
|
59
85
|
*
|
|
60
86
|
* @type {Cache<THREE.Material, StandardMaterial>}
|
|
@@ -65,7 +91,6 @@ export class PathTracedScene {
|
|
|
65
91
|
return mat.id
|
|
66
92
|
}
|
|
67
93
|
});
|
|
68
|
-
|
|
69
94
|
/**
|
|
70
95
|
*
|
|
71
96
|
* @type {function}
|
|
@@ -73,17 +98,96 @@ export class PathTracedScene {
|
|
|
73
98
|
*/
|
|
74
99
|
__background_sampler = make_vector3(0, 0, 0);
|
|
75
100
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
101
|
+
/**
|
|
102
|
+
*
|
|
103
|
+
* @returns {PathTracedMesh[]}
|
|
104
|
+
*/
|
|
105
|
+
get #meshes() {
|
|
106
|
+
return Array.from(this.meshes.values());
|
|
79
107
|
}
|
|
80
108
|
|
|
81
|
-
|
|
109
|
+
#rebuild_bvh() {
|
|
110
|
+
const meshes = this.#meshes;
|
|
111
|
+
|
|
112
|
+
const bounds = new AABB3();
|
|
113
|
+
|
|
114
|
+
const bvh = this.bvh_top_level;
|
|
115
|
+
|
|
116
|
+
if (bvh.root === NULL_NODE) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
bvh.node_get_aabb(bvh.root, bounds);
|
|
121
|
+
|
|
122
|
+
bvh.release_all();
|
|
123
|
+
|
|
124
|
+
const mesh_count = meshes.length;
|
|
125
|
+
const morton_codes = new Map();
|
|
126
|
+
|
|
127
|
+
for (let i = 0; i < mesh_count; i++) {
|
|
128
|
+
const mesh = meshes[i];
|
|
129
|
+
|
|
130
|
+
const center = mesh.aabb.getCenter();
|
|
131
|
+
|
|
132
|
+
const code = v3_morton_encode_bounded(center.x, center.y, center.z, bounds);
|
|
82
133
|
|
|
83
|
-
|
|
84
|
-
|
|
134
|
+
morton_codes.set(mesh, code);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
//
|
|
138
|
+
array_quick_sort_by_lookup_map(meshes, morton_codes, 0, mesh_count - 1);
|
|
139
|
+
|
|
140
|
+
const node_leaf_count = mesh_count;
|
|
141
|
+
const node_bin_count = max2(0, node_leaf_count - 1);
|
|
142
|
+
|
|
143
|
+
const node_total_count = node_leaf_count + node_bin_count;
|
|
144
|
+
|
|
145
|
+
const nodes = new Uint32Array(node_total_count);
|
|
146
|
+
|
|
147
|
+
// skip allocation calls, allocate exactly as many nodes as we need
|
|
148
|
+
bvh.node_capacity = node_total_count;
|
|
149
|
+
bvh.__size = node_total_count;
|
|
150
|
+
|
|
151
|
+
for (let i = 0; i < node_total_count; i++) {
|
|
152
|
+
// store nodes in reverse order so that top-level nodes end up on top
|
|
153
|
+
nodes[i] = (node_total_count - 1) - i;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// assign leaves
|
|
157
|
+
for (let i = 0; i < node_leaf_count; i++) {
|
|
158
|
+
const node = nodes[i];
|
|
159
|
+
|
|
160
|
+
const mesh = meshes[i];
|
|
161
|
+
|
|
162
|
+
bvh.node_set_aabb(node, mesh.aabb);
|
|
163
|
+
|
|
164
|
+
bvh.node_set_child1(node, NULL_NODE); //mark node as a leaf
|
|
165
|
+
bvh.node_set_user_data(node, mesh.id);
|
|
166
|
+
|
|
167
|
+
bvh.node_set_height(node, 0);
|
|
85
168
|
|
|
86
169
|
}
|
|
170
|
+
|
|
171
|
+
// record newly generated nodes as "unprocessed"
|
|
172
|
+
const unprocessed_nodes = new Uint32Array(node_leaf_count);
|
|
173
|
+
array_copy(nodes, 0, unprocessed_nodes, 0, node_leaf_count);
|
|
174
|
+
|
|
175
|
+
// assign root
|
|
176
|
+
bvh.__root = ebvh_build_hierarchy(bvh, unprocessed_nodes, node_leaf_count, nodes, node_leaf_count);
|
|
177
|
+
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
optimize() {
|
|
181
|
+
this.meshes.forEach((mesh, mesh_id) => {
|
|
182
|
+
mesh.build_tight_bounds();
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// re-build bvh from bottom up
|
|
186
|
+
this.#rebuild_bvh();
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async build() {
|
|
190
|
+
|
|
87
191
|
}
|
|
88
192
|
|
|
89
193
|
/**
|
|
@@ -122,47 +226,39 @@ export class PathTracedScene {
|
|
|
122
226
|
|
|
123
227
|
/**
|
|
124
228
|
*
|
|
125
|
-
* @param {
|
|
126
|
-
* @
|
|
127
|
-
* @param {mat4|number[]} transform
|
|
229
|
+
* @param {PathTracedMesh} mesh
|
|
230
|
+
* @returns {boolean}
|
|
128
231
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const mesh = new PathTracedMesh();
|
|
133
|
-
mesh.geometry = geo;
|
|
232
|
+
hasMesh(mesh) {
|
|
233
|
+
return this.#mesh_bvh_nodes.has(mesh);
|
|
234
|
+
}
|
|
134
235
|
|
|
135
|
-
|
|
236
|
+
/**
|
|
237
|
+
*
|
|
238
|
+
* @param {PathTracedMesh} mesh
|
|
239
|
+
* @returns {boolean}
|
|
240
|
+
*/
|
|
241
|
+
addMesh(mesh) {
|
|
242
|
+
if (this.hasMesh(mesh)) {
|
|
243
|
+
// already exists
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
136
246
|
|
|
137
|
-
mesh.
|
|
247
|
+
mesh.bvh = this.obtainGeometryBVH(mesh.geometry);
|
|
138
248
|
|
|
139
|
-
mesh.
|
|
249
|
+
mesh.update_bounds();
|
|
140
250
|
|
|
141
251
|
const bvh = this.bvh_top_level;
|
|
142
252
|
|
|
143
253
|
const bvh_node_id = bvh.allocate_node();
|
|
144
254
|
|
|
145
|
-
mesh
|
|
146
|
-
|
|
147
|
-
ensureGeometryBoundingBox(geo);
|
|
148
|
-
|
|
149
|
-
const aabb = [
|
|
150
|
-
geo.boundingBox.min.x,
|
|
151
|
-
geo.boundingBox.min.y,
|
|
152
|
-
geo.boundingBox.min.z,
|
|
153
|
-
geo.boundingBox.max.x,
|
|
154
|
-
geo.boundingBox.max.y,
|
|
155
|
-
geo.boundingBox.max.z,
|
|
156
|
-
];
|
|
157
|
-
|
|
158
|
-
const aabb_t = [];
|
|
159
|
-
|
|
160
|
-
aabb3_matrix4_project(aabb_t, aabb, transform);
|
|
255
|
+
this.#mesh_bvh_nodes.set(mesh, bvh_node_id);
|
|
161
256
|
|
|
162
257
|
bvh.node_set_aabb(
|
|
163
258
|
bvh_node_id,
|
|
164
|
-
|
|
259
|
+
mesh.aabb
|
|
165
260
|
);
|
|
261
|
+
|
|
166
262
|
bvh.node_set_user_data(
|
|
167
263
|
bvh_node_id,
|
|
168
264
|
mesh.id
|
|
@@ -170,6 +266,49 @@ export class PathTracedScene {
|
|
|
170
266
|
bvh.insert_leaf(bvh_node_id);
|
|
171
267
|
|
|
172
268
|
this.meshes.set(mesh.id, mesh);
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
*
|
|
276
|
+
* @param {PathTracedMesh} mesh
|
|
277
|
+
* @returns {boolean}
|
|
278
|
+
*/
|
|
279
|
+
removeMesh(mesh) {
|
|
280
|
+
|
|
281
|
+
if (!this.hasMesh(mesh)) {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const node_id = this.#mesh_bvh_nodes.get(mesh);
|
|
286
|
+
|
|
287
|
+
this.#mesh_bvh_nodes.delete(mesh);
|
|
288
|
+
|
|
289
|
+
this.bvh_top_level.remove_leaf(node_id);
|
|
290
|
+
this.bvh_top_level.release_node(node_id);
|
|
291
|
+
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
*
|
|
297
|
+
* @param {THREE.BufferGeometry} geometry
|
|
298
|
+
* @param {THREE.Material} material
|
|
299
|
+
* @param {mat4|number[]} transform
|
|
300
|
+
*/
|
|
301
|
+
createMesh(geometry, material, transform) {
|
|
302
|
+
const standard_material = this.#material_cache.getOrCompute(material, DEFAULT_CONVERTER.convert, DEFAULT_CONVERTER);
|
|
303
|
+
|
|
304
|
+
const mesh = new PathTracedMesh();
|
|
305
|
+
mesh.geometry = geometry;
|
|
306
|
+
|
|
307
|
+
mesh.material = standard_material;
|
|
308
|
+
|
|
309
|
+
mesh.transform = transform;
|
|
310
|
+
|
|
311
|
+
this.addMesh(mesh);
|
|
173
312
|
}
|
|
174
313
|
|
|
175
314
|
/**
|
|
@@ -205,35 +344,51 @@ export class PathTracedScene {
|
|
|
205
344
|
/**
|
|
206
345
|
*
|
|
207
346
|
* @param {number[]} out
|
|
208
|
-
* @param {number[]} ray
|
|
347
|
+
* @param {number[]|Ray3} ray
|
|
209
348
|
* @param {number} min_distance
|
|
210
349
|
* @param {number} max_distance
|
|
211
|
-
* @return {number}
|
|
350
|
+
* @return {number} distance to contact, or -1 if no contact found
|
|
212
351
|
*/
|
|
213
352
|
trace(out, ray, min_distance, max_distance) {
|
|
353
|
+
|
|
214
354
|
const bvh = this.bvh_top_level;
|
|
215
355
|
|
|
356
|
+
const ray_origin_x = ray[0];
|
|
357
|
+
const ray_origin_y = ray[1];
|
|
358
|
+
const ray_origin_z = ray[2];
|
|
359
|
+
|
|
360
|
+
const ray_direction_x = ray[3];
|
|
361
|
+
const ray_direction_y = ray[4];
|
|
362
|
+
const ray_direction_z = ray[5];
|
|
363
|
+
|
|
364
|
+
|
|
216
365
|
const hit_count = bvh_query_leaves_ray(
|
|
217
366
|
bvh, bvh.root,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
367
|
+
scratch_uint32_array, 0,
|
|
368
|
+
ray_origin_x, ray_origin_y, ray_origin_z,
|
|
369
|
+
ray_direction_x, ray_direction_y, ray_direction_z
|
|
221
370
|
);
|
|
222
371
|
|
|
223
372
|
let nearest_hit_distance = max_distance;
|
|
224
|
-
let nearest_mesh = null;
|
|
225
373
|
|
|
374
|
+
/*
|
|
375
|
+
For performance, we bind data directly to avoid extra copies required to read out AABB
|
|
376
|
+
*/
|
|
377
|
+
const float32 = bvh.__data_float32;
|
|
378
|
+
let best_node;
|
|
226
379
|
|
|
227
380
|
for (let i = 0; i < hit_count; i++) {
|
|
228
|
-
const node = temp_ray_results[i];
|
|
229
381
|
|
|
230
|
-
|
|
382
|
+
const node = scratch_uint32_array[i];
|
|
383
|
+
|
|
384
|
+
const node_address = node * ELEMENT_WORD_COUNT;
|
|
231
385
|
|
|
232
386
|
if (aabb3_unsigned_distance_sqr_to_point(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
387
|
+
float32[node_address], float32[node_address + 1], float32[node_address + 2],
|
|
388
|
+
float32[node_address + 3], float32[node_address + 4], float32[node_address + 5],
|
|
389
|
+
|
|
390
|
+
ray_origin_x, ray_origin_y, ray_origin_z
|
|
391
|
+
) > nearest_hit_distance * nearest_hit_distance ) {
|
|
237
392
|
// bounds of the mesh are too far
|
|
238
393
|
continue;
|
|
239
394
|
}
|
|
@@ -242,22 +397,19 @@ export class PathTracedScene {
|
|
|
242
397
|
|
|
243
398
|
const mesh = this.meshes.get(node_user_data);
|
|
244
399
|
|
|
245
|
-
const distance_to_hit = mesh.hit(
|
|
400
|
+
const distance_to_hit = mesh.hit(out, ray, min_distance, nearest_hit_distance);
|
|
246
401
|
|
|
247
402
|
if (distance_to_hit >= 0) {
|
|
248
403
|
// since raycast in leaf nodes is already bound by maximum distance, any hit we get is necessarily a closer hit than before
|
|
249
404
|
nearest_hit_distance = distance_to_hit;
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
array_copy(tmp_0, 0, out, 0, 11);
|
|
405
|
+
best_node = node;
|
|
253
406
|
}
|
|
254
407
|
}
|
|
255
408
|
|
|
256
409
|
if (nearest_hit_distance !== max_distance) {
|
|
257
410
|
|
|
258
|
-
// out[6] = nearest_mesh;
|
|
259
|
-
|
|
260
411
|
return nearest_hit_distance;
|
|
412
|
+
|
|
261
413
|
}
|
|
262
414
|
|
|
263
415
|
return -1;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { vec3 } from "gl-matrix";
|
|
2
2
|
import { array_copy } from "../../../../core/collection/array/array_copy.js";
|
|
3
|
-
import { getBiasedNormalSample } from "./getBiasedNormalSample.js";
|
|
3
|
+
import { getBiasedNormalSample } from "./sampling/getBiasedNormalSample.js";
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
Ray hit data layout:
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number[]} result
|
|
4
|
+
* @param {number} result_offset
|
|
5
|
+
* @param {BVH} bvh
|
|
6
|
+
* @param {number[]} node_list
|
|
7
|
+
* @param {number} node_list_offset
|
|
8
|
+
* @param {number} node_list_size
|
|
9
|
+
* @param {number} plane_normal_x
|
|
10
|
+
* @param {number} plane_normal_y
|
|
11
|
+
* @param {number} plane_normal_z
|
|
12
|
+
* @param {number} plane_offset
|
|
13
|
+
*/
|
|
14
|
+
export function build_bvh_nodes_distances_along_ray(result: number[], result_offset: number, bvh: BVH, node_list: number[], node_list_offset: number, node_list_size: number, plane_normal_x: number, plane_normal_y: number, plane_normal_z: number, plane_offset: number): void;
|
|
15
|
+
//# sourceMappingURL=build_bvh_nodes_distances_along_ray.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_bvh_nodes_distances_along_ray.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AACH,4DAXW,MAAM,EAAE,iBACR,MAAM,uBAEN,MAAM,EAAE,oBACR,MAAM,kBACN,MAAM,kBACN,MAAM,kBACN,MAAM,kBACN,MAAM,gBACN,MAAM,QA4BhB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ELEMENT_WORD_COUNT } from "../../../../core/bvh2/bvh3/BVH.js";
|
|
2
|
+
import {
|
|
3
|
+
aabb3_compute_distance_above_plane_min
|
|
4
|
+
} from "../../../../core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {number[]} result
|
|
9
|
+
* @param {number} result_offset
|
|
10
|
+
* @param {BVH} bvh
|
|
11
|
+
* @param {number[]} node_list
|
|
12
|
+
* @param {number} node_list_offset
|
|
13
|
+
* @param {number} node_list_size
|
|
14
|
+
* @param {number} plane_normal_x
|
|
15
|
+
* @param {number} plane_normal_y
|
|
16
|
+
* @param {number} plane_normal_z
|
|
17
|
+
* @param {number} plane_offset
|
|
18
|
+
*/
|
|
19
|
+
export function build_bvh_nodes_distances_along_ray(
|
|
20
|
+
result, result_offset,
|
|
21
|
+
bvh,
|
|
22
|
+
node_list, node_list_offset, node_list_size,
|
|
23
|
+
plane_normal_x, plane_normal_y, plane_normal_z,
|
|
24
|
+
plane_offset
|
|
25
|
+
) {
|
|
26
|
+
/*
|
|
27
|
+
For performance, we bind data directly to avoid extra copies required to read out AABB
|
|
28
|
+
*/
|
|
29
|
+
const float32 = bvh.__data_float32;
|
|
30
|
+
|
|
31
|
+
for (let i = 0; i < node_list_size; i++) {
|
|
32
|
+
|
|
33
|
+
const node = node_list[i + node_list_offset];
|
|
34
|
+
|
|
35
|
+
const address = node * ELEMENT_WORD_COUNT;
|
|
36
|
+
|
|
37
|
+
const distance = aabb3_compute_distance_above_plane_min(
|
|
38
|
+
plane_normal_x, plane_normal_y, plane_normal_z, plane_offset,
|
|
39
|
+
float32[address], float32[address + 1], float32[address + 2],
|
|
40
|
+
float32[address + 3], float32[address + 4], float32[address + 5]
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
result[result_offset + i] = distance;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number[]} result
|
|
4
|
+
* @param {number} result_offset
|
|
5
|
+
* @param {BVH} bvh
|
|
6
|
+
* @param {number[]} node_list
|
|
7
|
+
* @param {number} node_list_offset
|
|
8
|
+
* @param {number} node_list_size
|
|
9
|
+
* @param {number} x
|
|
10
|
+
* @param {number} y
|
|
11
|
+
* @param {number} z
|
|
12
|
+
*/
|
|
13
|
+
export function build_bvh_nodes_distances_sqr_to_point(result: number[], result_offset: number, bvh: BVH, node_list: number[], node_list_offset: number, node_list_size: number, x: number, y: number, z: number): void;
|
|
14
|
+
//# sourceMappingURL=build_bvh_nodes_distances_sqr_to_point.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build_bvh_nodes_distances_sqr_to_point.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,+DAVW,MAAM,EAAE,iBACR,MAAM,uBAEN,MAAM,EAAE,oBACR,MAAM,kBACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QA2BhB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ELEMENT_WORD_COUNT } from "../../../../core/bvh2/bvh3/BVH.js";
|
|
2
|
+
import {
|
|
3
|
+
aabb3_unsigned_distance_sqr_to_point
|
|
4
|
+
} from "../../../../core/geom/3d/aabb/aabb3_unsigned_distance_sqr_to_point.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {number[]} result
|
|
9
|
+
* @param {number} result_offset
|
|
10
|
+
* @param {BVH} bvh
|
|
11
|
+
* @param {number[]} node_list
|
|
12
|
+
* @param {number} node_list_offset
|
|
13
|
+
* @param {number} node_list_size
|
|
14
|
+
* @param {number} x
|
|
15
|
+
* @param {number} y
|
|
16
|
+
* @param {number} z
|
|
17
|
+
*/
|
|
18
|
+
export function build_bvh_nodes_distances_sqr_to_point(
|
|
19
|
+
result, result_offset,
|
|
20
|
+
bvh,
|
|
21
|
+
node_list, node_list_offset, node_list_size,
|
|
22
|
+
x, y, z
|
|
23
|
+
) {
|
|
24
|
+
/*
|
|
25
|
+
For performance, we bind data directly to avoid extra copies required to read out AABB
|
|
26
|
+
*/
|
|
27
|
+
const float32 = bvh.__data_float32;
|
|
28
|
+
|
|
29
|
+
for (let i = 0; i < node_list_size; i++) {
|
|
30
|
+
|
|
31
|
+
const node = node_list[i + node_list_offset];
|
|
32
|
+
|
|
33
|
+
const address = node * ELEMENT_WORD_COUNT;
|
|
34
|
+
|
|
35
|
+
const distance = aabb3_unsigned_distance_sqr_to_point(
|
|
36
|
+
float32[address], float32[address + 1], float32[address + 2],
|
|
37
|
+
float32[address + 3], float32[address + 4], float32[address + 5],
|
|
38
|
+
x, y, z
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
result[result_offset + i] = distance;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compute_triangle_group_aabb3.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/path_tracer/geometry/compute_triangle_group_aabb3.js"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,qDARW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,WACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,aAC1B,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,gBAC1B,MAAM,eACN,MAAM,mBACN,MAAM,QAkChB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { max2 } from "
|
|
2
|
-
import { min2 } from "
|
|
1
|
+
import { max2 } from "../../../../../core/math/max2.js";
|
|
2
|
+
import { min2 } from "../../../../../core/math/min2.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Compute AABB for a group of triangles based on index-buffer
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number[]} output
|
|
4
|
+
* @param {number[]} indices
|
|
5
|
+
* @param {number[]} positions
|
|
6
|
+
* @param {number} face_index
|
|
7
|
+
* @param {number} t
|
|
8
|
+
* @param {number} u
|
|
9
|
+
* @param {number} v
|
|
10
|
+
*/
|
|
11
|
+
export function construct_ray_hit_from_geometry(output: number[], indices: number[], positions: number[], face_index: number, t: number, u: number, v: number): void;
|
|
12
|
+
//# sourceMappingURL=construct_ray_hit_from_geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"construct_ray_hit_from_geometry.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/path_tracer/geometry/construct_ray_hit_from_geometry.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wDARW,MAAM,EAAE,WACR,MAAM,EAAE,aACR,MAAM,EAAE,cACR,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QA+DhB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number[]} output
|
|
4
|
+
* @param {number[]} indices
|
|
5
|
+
* @param {number[]} positions
|
|
6
|
+
* @param {number} face_index
|
|
7
|
+
* @param {number} t
|
|
8
|
+
* @param {number} u
|
|
9
|
+
* @param {number} v
|
|
10
|
+
*/
|
|
11
|
+
export function construct_ray_hit_from_geometry(
|
|
12
|
+
output,
|
|
13
|
+
indices, positions,
|
|
14
|
+
face_index,
|
|
15
|
+
t, u, v
|
|
16
|
+
) {
|
|
17
|
+
|
|
18
|
+
const index_offset = face_index * 3;
|
|
19
|
+
|
|
20
|
+
const a = indices[index_offset];
|
|
21
|
+
const b = indices[index_offset + 1];
|
|
22
|
+
const c = indices[index_offset + 2];
|
|
23
|
+
|
|
24
|
+
const a_address = a * 3;
|
|
25
|
+
const b_address = b * 3;
|
|
26
|
+
const c_address = c * 3;
|
|
27
|
+
|
|
28
|
+
const ax = positions[a_address];
|
|
29
|
+
const ay = positions[a_address + 1];
|
|
30
|
+
const az = positions[a_address + 2];
|
|
31
|
+
|
|
32
|
+
const bx = positions[b_address];
|
|
33
|
+
const by = positions[b_address + 1];
|
|
34
|
+
const bz = positions[b_address + 2];
|
|
35
|
+
|
|
36
|
+
const cx = positions[c_address];
|
|
37
|
+
const cy = positions[c_address + 1];
|
|
38
|
+
const cz = positions[c_address + 2];
|
|
39
|
+
|
|
40
|
+
// normal
|
|
41
|
+
|
|
42
|
+
// edge1 = a - b
|
|
43
|
+
const edge1_x = bx - ax;
|
|
44
|
+
const edge1_y = by - ay;
|
|
45
|
+
const edge1_z = bz - az;
|
|
46
|
+
|
|
47
|
+
// edge2 = c - a
|
|
48
|
+
const edge2_x = cx - ax;
|
|
49
|
+
const edge2_y = cy - ay;
|
|
50
|
+
const edge2_z = cz - az;
|
|
51
|
+
|
|
52
|
+
// compute position of intersection point
|
|
53
|
+
output[0] = ax + edge1_x * u + edge2_x * v;
|
|
54
|
+
output[1] = ay + edge1_y * u + edge2_y * v;
|
|
55
|
+
output[2] = az + edge1_z * u + edge2_z * v;
|
|
56
|
+
|
|
57
|
+
// Compute triangle normal
|
|
58
|
+
|
|
59
|
+
// normal = edge1 x edge2
|
|
60
|
+
const normal_x = edge1_y * edge2_z - edge1_z * edge2_y;
|
|
61
|
+
const normal_y = edge1_z * edge2_x - edge1_x * edge2_z;
|
|
62
|
+
const normal_z = edge1_x * edge2_y - edge1_y * edge2_x
|
|
63
|
+
|
|
64
|
+
output[3] = normal_x;
|
|
65
|
+
output[4] = normal_y;
|
|
66
|
+
output[5] = normal_z;
|
|
67
|
+
|
|
68
|
+
output[6] = t;
|
|
69
|
+
output[7] = u;
|
|
70
|
+
output[8] = v;
|
|
71
|
+
output[9] = face_index;
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sample_triangle_attribute.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/path_tracer/geometry/sample_triangle_attribute.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,+CAVW,MAAM,EAAE,cACR,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,mBACN,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,YAAY,cACvC,MAAM,KACN,MAAM,KACN,MAAM,QAwBhB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number[]} triangles
|
|
4
|
+
* @param {number} offset
|
|
5
|
+
* @param {number} count
|
|
6
|
+
* @param {number} point_x
|
|
7
|
+
* @param {number} point_y
|
|
8
|
+
* @param {number} point_z
|
|
9
|
+
* @param morton_codes
|
|
10
|
+
* @param bounds
|
|
11
|
+
*/
|
|
12
|
+
export function sort_triangles_by_distance_to_point(triangles: number[], offset: number, count: number, morton_codes: any, bounds: any, point_x: number, point_y: number, point_z: number): void;
|
|
13
|
+
//# sourceMappingURL=sort_triangles_by_distance_to_point.d.ts.map
|
package/src/engine/graphics/sh3/path_tracer/geometry/sort_triangles_by_distance_to_point.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort_triangles_by_distance_to_point.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/graphics/sh3/path_tracer/geometry/sort_triangles_by_distance_to_point.js"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,+DATW,MAAM,EAAE,UACR,MAAM,SACN,MAAM,2CACN,MAAM,WACN,MAAM,WACN,MAAM,QAoChB"}
|