@woosh/meep-engine 2.109.1 → 2.109.3

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.
Files changed (276) hide show
  1. package/build/meep.cjs +126 -186
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +126 -186
  4. package/package.json +1 -1
  5. package/src/core/binary/ctz32.d.ts.map +1 -1
  6. package/src/core/binary/ctz32.js +12 -11
  7. package/src/core/binary/reinterpret_int32_as_float32.d.ts +7 -0
  8. package/src/core/binary/reinterpret_int32_as_float32.d.ts.map +1 -0
  9. package/src/core/binary/reinterpret_int32_as_float32.js +14 -0
  10. package/src/core/binary/reverse_bits_uint32.d.ts +8 -0
  11. package/src/core/binary/reverse_bits_uint32.d.ts.map +1 -0
  12. package/src/core/binary/reverse_bits_uint32.js +17 -0
  13. package/src/core/binary/reverse_bits_uint32.spec.d.ts +2 -0
  14. package/src/core/binary/reverse_bits_uint32.spec.d.ts.map +1 -0
  15. package/src/core/binary/reverse_bits_uint32.spec.js +18 -0
  16. package/src/core/bvh2/bvh3/BVH.d.ts.map +1 -1
  17. package/src/core/bvh2/bvh3/BVH.js +13 -18
  18. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.d.ts.map +1 -1
  19. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.js +3 -1
  20. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
  21. package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +6 -7
  22. package/src/core/bvh2/bvh3/ebvh_build_hierarchy.d.ts.map +1 -1
  23. package/src/core/bvh2/bvh3/ebvh_build_hierarchy.js +4 -0
  24. package/src/core/bvh2/bvh3/query/backtracking/bvh_backtracking_query_leaves_ray.d.ts +16 -0
  25. package/src/core/bvh2/bvh3/query/backtracking/bvh_backtracking_query_leaves_ray.d.ts.map +1 -0
  26. package/src/core/bvh2/bvh3/query/backtracking/bvh_backtracking_query_leaves_ray.js +130 -0
  27. package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray_segment.d.ts +18 -0
  28. package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray_segment.d.ts.map +1 -0
  29. package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray_segment.js +94 -0
  30. package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray_segment.d.ts +18 -0
  31. package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray_segment.d.ts.map +1 -0
  32. package/src/core/bvh2/bvh3/query/bvh_query_user_data_ray_segment.js +100 -0
  33. package/src/core/bvh2/bvh3/query/cache/BVH_QUERY_CACHE_SIZE.d.ts +2 -0
  34. package/src/core/bvh2/bvh3/query/cache/BVH_QUERY_CACHE_SIZE.d.ts.map +1 -0
  35. package/src/core/bvh2/bvh3/query/cache/BVH_QUERY_CACHE_SIZE.js +1 -0
  36. package/src/core/bvh2/bvh3/query/cache/bvh_query_cache_hash_v3.d.ts +9 -0
  37. package/src/core/bvh2/bvh3/query/cache/bvh_query_cache_hash_v3.d.ts.map +1 -0
  38. package/src/core/bvh2/bvh3/query/cache/bvh_query_cache_hash_v3.js +31 -0
  39. package/src/core/collection/array/array_quick_sort_by_lookup_map.d.ts +9 -0
  40. package/src/core/collection/array/array_quick_sort_by_lookup_map.d.ts.map +1 -0
  41. package/src/core/collection/array/array_quick_sort_by_lookup_map.js +79 -0
  42. package/src/core/collection/array/array_quick_sort_by_lookup_uint.d.ts +8 -0
  43. package/src/core/collection/array/array_quick_sort_by_lookup_uint.d.ts.map +1 -0
  44. package/src/core/collection/array/{array_quick_sort_by_lookup.js → array_quick_sort_by_lookup_uint.js} +1 -1
  45. package/src/core/collection/array/array_shuffle.js +1 -1
  46. package/src/core/collection/array/array_swap_one.d.ts.map +1 -1
  47. package/src/core/collection/array/array_swap_one.js +6 -0
  48. package/src/core/collection/map/HashMap.js +2 -2
  49. package/src/core/events/signal/Signal.d.ts.map +1 -1
  50. package/src/core/events/signal/Signal.js +10 -10
  51. package/src/core/geom/2d/compute_triangle_area_2d.d.ts.map +1 -1
  52. package/src/core/geom/2d/compute_triangle_area_2d.js +5 -3
  53. package/src/core/geom/3d/Ray3.d.ts +6 -0
  54. package/src/core/geom/3d/Ray3.d.ts.map +1 -1
  55. package/src/core/geom/3d/Ray3.js +24 -0
  56. package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.d.ts +16 -0
  57. package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.d.ts.map +1 -0
  58. package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.js +29 -0
  59. package/src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.d.ts +2 -2
  60. package/src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.d.ts.map +1 -1
  61. package/src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.js +6 -6
  62. package/src/core/geom/3d/aabb/aabb3_intersects_ray_segment.d.ts +21 -0
  63. package/src/core/geom/3d/aabb/aabb3_intersects_ray_segment.d.ts.map +1 -0
  64. package/src/core/geom/3d/aabb/aabb3_intersects_ray_segment.js +67 -0
  65. package/src/core/geom/3d/eulerAnglesFromMatrix.d.ts +2 -2
  66. package/src/core/geom/3d/eulerAnglesFromMatrix.d.ts.map +1 -1
  67. package/src/core/geom/3d/eulerAnglesFromMatrix.js +28 -25
  68. package/src/core/geom/3d/morton/v3_morton_encode_bounded.d.ts +2 -2
  69. package/src/core/geom/3d/morton/v3_morton_encode_bounded.d.ts.map +1 -1
  70. package/src/core/geom/3d/morton/v3_morton_encode_bounded.js +1 -1
  71. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts +2 -2
  72. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.d.ts.map +1 -1
  73. package/src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js +1 -1
  74. package/src/core/geom/3d/ray/ray3_interval_array_apply_matrix4.d.ts +11 -0
  75. package/src/core/geom/3d/ray/ray3_interval_array_apply_matrix4.d.ts.map +1 -0
  76. package/src/core/geom/3d/ray/ray3_interval_array_apply_matrix4.js +61 -0
  77. package/src/core/geom/3d/ray/ray3_shift_origin_along_direction.js +2 -2
  78. package/src/core/geom/3d/sphere/sphere_intersects_ray.js +1 -1
  79. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.d.ts.map +1 -1
  80. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.js +24 -188
  81. package/src/core/geom/3d/tetrahedra/triangle/prototype.js +1 -1
  82. package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.d.ts +11 -0
  83. package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.d.ts.map +1 -0
  84. package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.js +42 -0
  85. package/src/core/geom/3d/topology/samples/sampleFloodFill.js +2 -2
  86. package/src/core/geom/3d/topology/tm_face_area.js +2 -2
  87. package/src/core/geom/3d/triangle/{computeTriangleSurfaceArea.d.ts → compute_triangle_area_3d.d.ts} +2 -2
  88. package/src/core/geom/3d/triangle/compute_triangle_area_3d.d.ts.map +1 -0
  89. package/src/core/geom/3d/triangle/{computeTriangleSurfaceArea.js → compute_triangle_area_3d.js} +2 -4
  90. package/src/core/geom/Quaternion.d.ts.map +1 -1
  91. package/src/core/geom/Quaternion.js +13 -102
  92. package/src/core/geom/Quaternion.spec.js +2 -2
  93. package/src/core/geom/Vector1.d.ts.map +1 -1
  94. package/src/core/geom/Vector1.js +14 -6
  95. package/src/core/geom/vec3/v3_array_displace_in_direction.d.ts +14 -0
  96. package/src/core/geom/vec3/v3_array_displace_in_direction.d.ts.map +1 -0
  97. package/src/core/geom/vec3/{v3_shift_along_direction.js → v3_array_displace_in_direction.js} +1 -1
  98. package/src/core/geom/vec3/v3_displace_in_direction.d.ts +7 -7
  99. package/src/core/geom/vec3/v3_displace_in_direction.d.ts.map +1 -1
  100. package/src/core/geom/vec3/v3_displace_in_direction.js +20 -17
  101. package/src/core/geom/vec3/v3_displace_in_direction.spec.d.ts +2 -0
  102. package/src/core/geom/vec3/v3_displace_in_direction.spec.d.ts.map +1 -0
  103. package/src/core/geom/vec3/v3_displace_in_direction.spec.js +80 -0
  104. package/src/core/geom/vec4/v4_length.d.ts +10 -0
  105. package/src/core/geom/vec4/v4_length.d.ts.map +1 -0
  106. package/src/core/geom/vec4/v4_length.js +13 -0
  107. package/src/core/geom/vec4/v4_length_sqr.js +2 -1
  108. package/src/core/graph/eigen/matrix_eigenvalues_in_place.spec.js +31 -1
  109. package/src/core/math/FLT_EPSILON_64.d.ts +6 -0
  110. package/src/core/math/FLT_EPSILON_64.d.ts.map +1 -0
  111. package/src/core/math/FLT_EPSILON_64.js +5 -0
  112. package/src/core/math/gaussian.d.ts +2 -2
  113. package/src/core/math/gaussian.js +2 -2
  114. package/src/core/math/linalg/README.md +1 -0
  115. package/src/core/math/linalg/lu_factor_linear_system.d.ts +13 -0
  116. package/src/core/math/linalg/lu_factor_linear_system.d.ts.map +1 -0
  117. package/src/core/math/linalg/lu_factor_linear_system.js +112 -0
  118. package/src/core/math/linalg/lu_solve_linear_system.d.ts +14 -0
  119. package/src/core/math/linalg/lu_solve_linear_system.d.ts.map +1 -0
  120. package/src/core/math/linalg/lu_solve_linear_system.js +51 -0
  121. package/src/core/math/linalg/solve_linear_system.d.ts +14 -0
  122. package/src/core/math/linalg/solve_linear_system.d.ts.map +1 -0
  123. package/src/core/math/linalg/solve_linear_system.js +52 -0
  124. package/src/core/math/linalg/solve_linear_system.spec.d.ts +2 -0
  125. package/src/core/math/linalg/solve_linear_system.spec.d.ts.map +1 -0
  126. package/src/core/math/linalg/solve_linear_system.spec.js +70 -0
  127. package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts +10 -0
  128. package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts.map +1 -0
  129. package/src/core/math/linalg/solve_linear_system_GEPP_2x2.js +91 -0
  130. package/src/core/math/max4.d.ts +10 -0
  131. package/src/core/math/max4.d.ts.map +1 -0
  132. package/src/core/math/max4.js +24 -0
  133. package/src/core/math/min4.d.ts +10 -0
  134. package/src/core/math/min4.d.ts.map +1 -0
  135. package/src/core/math/min4.js +23 -0
  136. package/src/core/math/solveQuadratic.d.ts.map +1 -1
  137. package/src/core/math/solveQuadratic.js +2 -0
  138. package/src/core/math/statistics/gaussian_amplitude.d.ts +8 -0
  139. package/src/core/math/statistics/gaussian_amplitude.d.ts.map +1 -0
  140. package/src/core/math/statistics/gaussian_amplitude.js +13 -0
  141. package/src/core/math/statistics/halton_sequence.js +3 -3
  142. package/src/core/math/statistics/halton_sequence.spec.js +18 -0
  143. package/src/core/math/statistics/hammersley_sequence.d.ts +9 -0
  144. package/src/core/math/statistics/hammersley_sequence.d.ts.map +1 -0
  145. package/src/core/math/statistics/hammersley_sequence.js +25 -0
  146. package/src/core/math/statistics/hammersley_sequence_2d.d.ts +9 -0
  147. package/src/core/math/statistics/hammersley_sequence_2d.d.ts.map +1 -0
  148. package/src/core/math/statistics/hammersley_sequence_2d.js +17 -0
  149. package/src/core/math/statistics/radical_inverse_VdC_base_2.d.ts +8 -0
  150. package/src/core/math/statistics/radical_inverse_VdC_base_2.d.ts.map +1 -0
  151. package/src/core/math/statistics/radical_inverse_VdC_base_2.js +15 -0
  152. package/src/core/math/statistics/radical_inverse_VdC_base_2.spec.d.ts +2 -0
  153. package/src/core/math/statistics/radical_inverse_VdC_base_2.spec.d.ts.map +1 -0
  154. package/src/core/math/statistics/radical_inverse_VdC_base_2.spec.js +9 -0
  155. package/src/core/model/node-graph/node/NodeInstance.d.ts.map +1 -1
  156. package/src/core/model/node-graph/node/NodeInstance.js +26 -12
  157. package/src/core/model/node-graph/node/NodeInstance.spec.d.ts +2 -0
  158. package/src/core/model/node-graph/node/NodeInstance.spec.d.ts.map +1 -0
  159. package/src/core/model/node-graph/node/NodeInstance.spec.js +82 -0
  160. package/src/core/model/node-graph/node/NodeInstancePortReference.d.ts.map +1 -1
  161. package/src/core/model/node-graph/node/NodeInstancePortReference.js +9 -0
  162. package/src/core/model/node-graph/node/NodeInstancePortReference.spec.js +20 -0
  163. package/src/core/model/node-graph/node/Port.d.ts.map +1 -1
  164. package/src/core/model/node-graph/node/Port.js +5 -12
  165. package/src/core/model/node-graph/node/PortDirection.d.ts.map +1 -1
  166. package/src/core/model/node-graph/node/PortDirection.js +7 -1
  167. package/src/engine/asset/CORS/CrossOriginConfig.d.ts.map +1 -1
  168. package/src/engine/asset/CORS/CrossOriginConfig.js +6 -4
  169. package/src/engine/graphics/geometry/buffered/computeBufferAttributeHash.d.ts.map +1 -1
  170. package/src/engine/graphics/geometry/buffered/computeBufferAttributeHash.js +9 -5
  171. package/src/engine/graphics/geometry/computeMeshSurfaceArea.js +2 -2
  172. package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.d.ts.map +1 -1
  173. package/src/engine/graphics/impostors/octahedral/grid/OctahedralUvEncoder.js +33 -3
  174. package/src/engine/graphics/impostors/octahedral/prototypeBaker.js +12 -9
  175. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_INFERNO.d.ts +6 -0
  176. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_INFERNO.d.ts.map +1 -0
  177. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_INFERNO.js +18 -0
  178. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_TURBO.d.ts +6 -0
  179. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_TURBO.d.ts.map +1 -0
  180. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_TURBO.js +266 -0
  181. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_VIRIDIS.d.ts +7 -0
  182. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_VIRIDIS.d.ts.map +1 -0
  183. package/src/engine/graphics/particles/particular/engine/parameter/sample/RGB_LUT_VIRIDIS.js +19 -0
  184. package/src/engine/graphics/sh3/SH3VisualisationMaterial.js +9 -9
  185. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.d.ts.map +1 -1
  186. package/src/engine/graphics/sh3/gi/material/MaterialTransformer.js +0 -2
  187. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts +4 -27
  188. package/src/engine/graphics/sh3/lpv/LightProbeVolume.d.ts.map +1 -1
  189. package/src/engine/graphics/sh3/lpv/LightProbeVolume.js +36 -158
  190. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts +13 -0
  191. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.d.ts.map +1 -0
  192. package/src/engine/graphics/sh3/lpv/LightProbeVolumeBaker.js +63 -0
  193. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts +1 -0
  194. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.d.ts.map +1 -1
  195. package/src/engine/graphics/sh3/lpv/PathTracerProbeRenderer.js +25 -1
  196. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.d.ts.map +1 -1
  197. package/src/engine/graphics/sh3/lpv/build_probes_for_scene.js +4 -29
  198. package/src/engine/graphics/sh3/lpv/{LightProbeVolumeSerializationAdapter.d.ts → serialization/LightProbeVolumeSerializationAdapter.d.ts} +2 -2
  199. package/src/engine/graphics/sh3/lpv/serialization/LightProbeVolumeSerializationAdapter.d.ts.map +1 -0
  200. package/src/engine/graphics/sh3/lpv/{LightProbeVolumeSerializationAdapter.js → serialization/LightProbeVolumeSerializationAdapter.js} +2 -2
  201. package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts +13 -0
  202. package/src/engine/graphics/sh3/lpv/sh3_bake_depth.d.ts.map +1 -0
  203. package/src/engine/graphics/sh3/lpv/sh3_bake_depth.js +71 -0
  204. package/src/engine/graphics/sh3/lpv/worker/lpv_build_worker.d.ts +2 -0
  205. package/src/engine/graphics/sh3/lpv/worker/lpv_build_worker.d.ts.map +1 -0
  206. package/src/engine/graphics/sh3/lpv/worker/lpv_build_worker.js +38 -0
  207. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts +1 -7
  208. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -1
  209. package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +34 -148
  210. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.d.ts +13 -9
  211. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.d.ts.map +1 -1
  212. package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +75 -55
  213. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts +23 -5
  214. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
  215. package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +201 -72
  216. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +1 -1
  217. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts +15 -0
  218. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.d.ts.map +1 -0
  219. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_along_ray.js +46 -0
  220. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts +14 -0
  221. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.d.ts.map +1 -0
  222. package/src/engine/graphics/sh3/path_tracer/build_bvh_nodes_distances_sqr_to_point.js +43 -0
  223. package/src/engine/graphics/sh3/path_tracer/geometry/compute_triangle_group_aabb3.d.ts.map +1 -0
  224. package/src/engine/graphics/sh3/path_tracer/{compute_triangle_group_aabb3.js → geometry/compute_triangle_group_aabb3.js} +2 -2
  225. package/src/engine/graphics/sh3/path_tracer/geometry/construct_ray_hit_from_geometry.d.ts +12 -0
  226. package/src/engine/graphics/sh3/path_tracer/geometry/construct_ray_hit_from_geometry.d.ts.map +1 -0
  227. package/src/engine/graphics/sh3/path_tracer/geometry/construct_ray_hit_from_geometry.js +72 -0
  228. package/src/engine/graphics/sh3/path_tracer/geometry/sample_triangle_attribute.d.ts.map +1 -0
  229. package/src/engine/graphics/sh3/path_tracer/geometry/sort_triangles_by_distance_to_point.d.ts +13 -0
  230. package/src/engine/graphics/sh3/path_tracer/geometry/sort_triangles_by_distance_to_point.d.ts.map +1 -0
  231. package/src/engine/graphics/sh3/path_tracer/geometry/sort_triangles_by_distance_to_point.js +48 -0
  232. package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.d.ts +1 -0
  233. package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.d.ts.map +1 -1
  234. package/src/engine/graphics/sh3/path_tracer/material/StandardMaterial.js +4 -0
  235. package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.d.ts +1 -0
  236. package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.d.ts.map +1 -1
  237. package/src/engine/graphics/sh3/path_tracer/material/StandardTexture.js +8 -5
  238. package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +27 -21
  239. package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.d.ts +2 -2
  240. package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.d.ts.map +1 -1
  241. package/src/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.js +1 -1
  242. package/src/engine/graphics/sh3/path_tracer/sampling/getBiasedNormalSample.d.ts.map +1 -0
  243. package/src/engine/graphics/sh3/path_tracer/{getBiasedNormalSample.js → sampling/getBiasedNormalSample.js} +1 -1
  244. package/src/engine/graphics/sh3/path_tracer/sampling/random_in_hemisphere.d.ts.map +1 -0
  245. package/src/engine/graphics/sh3/path_tracer/{random_in_hemisphere.js → sampling/random_in_hemisphere.js} +1 -1
  246. package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts +12 -0
  247. package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.d.ts.map +1 -0
  248. package/src/engine/graphics/sh3/path_tracer/sort_bvh_nodes_by_distance_to_point.js +46 -0
  249. package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +2 -2
  250. package/src/engine/graphics/sh3/path_tracer/three_object_to_path_traced_scene.d.ts +7 -0
  251. package/src/engine/graphics/sh3/path_tracer/three_object_to_path_traced_scene.d.ts.map +1 -0
  252. package/src/engine/graphics/sh3/path_tracer/three_object_to_path_traced_scene.js +69 -0
  253. package/src/engine/graphics/sh3/prototypeSH3Probe.js +29 -7
  254. package/src/engine/graphics/texture/formatToChannelCount.d.ts.map +1 -1
  255. package/src/engine/graphics/texture/formatToChannelCount.js +14 -1
  256. package/src/engine/graphics/three/three_object_replace_materials.d.ts +7 -0
  257. package/src/engine/graphics/three/three_object_replace_materials.d.ts.map +1 -0
  258. package/src/engine/graphics/three/three_object_replace_materials.js +13 -0
  259. package/src/core/collection/array/array_quick_sort_by_lookup.d.ts +0 -8
  260. package/src/core/collection/array/array_quick_sort_by_lookup.d.ts.map +0 -1
  261. package/src/core/geom/3d/triangle/computeTriangleSurfaceArea.d.ts.map +0 -1
  262. package/src/core/geom/vec3/v3_shift_along_direction.d.ts +0 -14
  263. package/src/core/geom/vec3/v3_shift_along_direction.d.ts.map +0 -1
  264. package/src/engine/graphics/filter/FlipArrayViaCanvas.d.ts +0 -2
  265. package/src/engine/graphics/filter/FlipArrayViaCanvas.d.ts.map +0 -1
  266. package/src/engine/graphics/filter/FlipArrayViaCanvas.js +0 -13
  267. package/src/engine/graphics/sh3/lpv/LightProbeVolumeSerializationAdapter.d.ts.map +0 -1
  268. package/src/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.d.ts.map +0 -1
  269. package/src/engine/graphics/sh3/path_tracer/getBiasedNormalSample.d.ts.map +0 -1
  270. package/src/engine/graphics/sh3/path_tracer/random_in_hemisphere.d.ts.map +0 -1
  271. package/src/engine/graphics/sh3/path_tracer/sample_triangle_attribute.d.ts.map +0 -1
  272. /package/src/engine/graphics/sh3/path_tracer/{compute_triangle_group_aabb3.d.ts → geometry/compute_triangle_group_aabb3.d.ts} +0 -0
  273. /package/src/engine/graphics/sh3/path_tracer/{sample_triangle_attribute.d.ts → geometry/sample_triangle_attribute.d.ts} +0 -0
  274. /package/src/engine/graphics/sh3/path_tracer/{sample_triangle_attribute.js → geometry/sample_triangle_attribute.js} +0 -0
  275. /package/src/engine/graphics/sh3/path_tracer/{getBiasedNormalSample.d.ts → sampling/getBiasedNormalSample.d.ts} +0 -0
  276. /package/src/engine/graphics/sh3/path_tracer/{random_in_hemisphere.d.ts → sampling/random_in_hemisphere.d.ts} +0 -0
@@ -1,33 +1,48 @@
1
1
  import { assert } from "../../../../core/assert.js";
2
- import { BVH } from "../../../../core/bvh2/bvh3/BVH.js";
3
- import { ebvh_sort_for_traversal_depth_first } from "../../../../core/bvh2/bvh3/ebvh_sort_for_traversal_depth_first.js";
4
- import { bvh_query_leaves_ray } from "../../../../core/bvh2/bvh3/query/bvh_query_leaves_ray.js";
2
+ import { BVH, NULL_NODE } from "../../../../core/bvh2/bvh3/BVH.js";
3
+ import { ebvh_build_hierarchy } from "../../../../core/bvh2/bvh3/ebvh_build_hierarchy.js";
4
+ import { bvh_query_user_data_ray_segment } from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_ray_segment.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 { aabb3_matrix4_project } from "../../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
9
- import {
10
- aabb3_unsigned_distance_sqr_to_point
11
- } from "../../../../core/geom/3d/aabb/aabb3_unsigned_distance_sqr_to_point.js";
9
+ import { AABB3 } from "../../../../core/geom/3d/aabb/AABB3.js";
10
+ import { v3_morton_encode_bounded } from "../../../../core/geom/3d/morton/v3_morton_encode_bounded.js";
12
11
  import { ray3_array_compose } from "../../../../core/geom/3d/ray/ray3_array_compose.js";
13
12
  import { v3_dot } from "../../../../core/geom/vec3/v3_dot.js";
13
+ import { max2 } from "../../../../core/math/max2.js";
14
14
  import { compute_geometry_polycount } from "../../geometry/compute_geometry_polycount.js";
15
15
  import { AbstractLight } from "../../render/forward_plus/model/AbstractLight.js";
16
- import { ensureGeometryBoundingBox } from "../../util/ensureGeometryBoundingBox.js";
17
16
  import { BufferedGeometryBVH } from "./BufferedGeometryBVH.js";
18
17
  import { make_vector3 } from "./make_one_vector3.js";
19
18
  import { MaterialConverter } from "./material/MaterialConverter.js";
20
19
  import { PathTracedMesh } from "./PathTracedMesh.js";
21
20
  import { sample_material } from "./texture/sample_material.js";
22
21
 
23
- const temp_ray_results = [];
22
+ /**
23
+ *
24
+ * @type {number[]|Uint32Array}
25
+ */
26
+ const scratch_uint32_array = new Uint32Array(4096);
27
+
24
28
  const _ray_1 = [];
25
- const tmp_0 = [];
29
+ const tmp_0 = new Float64Array(11);
26
30
  const null_output = [];
27
31
 
28
32
  const DEFAULT_CONVERTER = new MaterialConverter();
29
33
 
30
34
 
35
+ /**
36
+ *
37
+ * @param {Uint32Array} result
38
+ * @param {number} result_offset
39
+ * @param {number} count
40
+ * @param {BVH} bvh
41
+ */
42
+ function bvh_build_query_cache(result, result_offset, count, bvh) {
43
+
44
+ }
45
+
31
46
  export class PathTracedScene {
32
47
 
33
48
 
@@ -37,6 +52,7 @@ export class PathTracedScene {
37
52
  */
38
53
  bvh_top_level = new BVH();
39
54
 
55
+
40
56
  /**
41
57
  *
42
58
  * @type {Map<number, PathTracedMesh>}
@@ -55,6 +71,13 @@ export class PathTracedScene {
55
71
  */
56
72
  geo_cache = new Map();
57
73
 
74
+ /**
75
+ *
76
+ * @type {Map<PathTracedMesh, number>}
77
+ */
78
+ #mesh_bvh_nodes = new Map();
79
+
80
+
58
81
  /**
59
82
  *
60
83
  * @type {Cache<THREE.Material, StandardMaterial>}
@@ -65,7 +88,6 @@ export class PathTracedScene {
65
88
  return mat.id
66
89
  }
67
90
  });
68
-
69
91
  /**
70
92
  *
71
93
  * @type {function}
@@ -73,17 +95,96 @@ export class PathTracedScene {
73
95
  */
74
96
  __background_sampler = make_vector3(0, 0, 0);
75
97
 
76
- optimize() {
77
- this.bvh_top_level.trim();
78
- ebvh_sort_for_traversal_depth_first(this.bvh_top_level);
98
+ /**
99
+ *
100
+ * @returns {PathTracedMesh[]}
101
+ */
102
+ get #meshes() {
103
+ return Array.from(this.meshes.values());
79
104
  }
80
105
 
81
- async build() {
106
+ #rebuild_bvh() {
107
+ const meshes = this.#meshes;
108
+
109
+ const bounds = new AABB3();
110
+
111
+ const bvh = this.bvh_top_level;
112
+
113
+ if (bvh.root === NULL_NODE) {
114
+ return;
115
+ }
116
+
117
+ bvh.node_get_aabb(bvh.root, bounds);
118
+
119
+ bvh.release_all();
120
+
121
+ const mesh_count = meshes.length;
122
+ const morton_codes = new Map();
123
+
124
+ for (let i = 0; i < mesh_count; i++) {
125
+ const mesh = meshes[i];
126
+
127
+ const center = mesh.aabb.getCenter();
128
+
129
+ const code = v3_morton_encode_bounded(center.x, center.y, center.z, bounds);
82
130
 
83
- for (const [id, mesh] of this.meshes) {
84
- const material = mesh.material;
131
+ morton_codes.set(mesh, code);
132
+ }
133
+
134
+ //
135
+ array_quick_sort_by_lookup_map(meshes, morton_codes, 0, mesh_count - 1);
136
+
137
+ const node_leaf_count = mesh_count;
138
+ const node_bin_count = max2(0, node_leaf_count - 1);
139
+
140
+ const node_total_count = node_leaf_count + node_bin_count;
141
+
142
+ const nodes = new Uint32Array(node_total_count);
143
+
144
+ // skip allocation calls, allocate exactly as many nodes as we need
145
+ bvh.node_capacity = node_total_count;
146
+ bvh.__size = node_total_count;
147
+
148
+ for (let i = 0; i < node_total_count; i++) {
149
+ // store nodes in reverse order so that top-level nodes end up on top
150
+ nodes[i] = (node_total_count - 1) - i;
151
+ }
152
+
153
+ // assign leaves
154
+ for (let i = 0; i < node_leaf_count; i++) {
155
+ const node = nodes[i];
156
+
157
+ const mesh = meshes[i];
158
+
159
+ bvh.node_set_aabb(node, mesh.aabb);
160
+
161
+ bvh.node_set_child1(node, NULL_NODE); //mark node as a leaf
162
+ bvh.node_set_user_data(node, mesh.id);
163
+
164
+ bvh.node_set_height(node, 0);
85
165
 
86
166
  }
167
+
168
+ // record newly generated nodes as "unprocessed"
169
+ const unprocessed_nodes = new Uint32Array(node_leaf_count);
170
+ array_copy(nodes, 0, unprocessed_nodes, 0, node_leaf_count);
171
+
172
+ // assign root
173
+ bvh.__root = ebvh_build_hierarchy(bvh, unprocessed_nodes, node_leaf_count, nodes, node_leaf_count);
174
+
175
+ }
176
+
177
+ optimize() {
178
+ this.meshes.forEach((mesh, mesh_id) => {
179
+ mesh.build_tight_bounds();
180
+ });
181
+
182
+ // re-build bvh from bottom up
183
+ this.#rebuild_bvh();
184
+ }
185
+
186
+ async build() {
187
+
87
188
  }
88
189
 
89
190
  /**
@@ -122,47 +223,39 @@ export class PathTracedScene {
122
223
 
123
224
  /**
124
225
  *
125
- * @param {THREE.BufferGeometry} geo
126
- * @param {THREE.Material} material
127
- * @param {mat4|number[]} transform
226
+ * @param {PathTracedMesh} mesh
227
+ * @returns {boolean}
128
228
  */
129
- addMesh(geo, material, transform) {
130
- //meshopt_optimizeVertexCache(geo.getIndex().array, geo.getIndex().array, geo.getIndex().array.length, geo.getAttribute('position').count);
131
-
132
- const mesh = new PathTracedMesh();
133
- mesh.geometry = geo;
229
+ hasMesh(mesh) {
230
+ return this.#mesh_bvh_nodes.has(mesh);
231
+ }
134
232
 
135
- mesh.material = this.#material_cache.getOrCompute(material, DEFAULT_CONVERTER.convert, DEFAULT_CONVERTER);
233
+ /**
234
+ *
235
+ * @param {PathTracedMesh} mesh
236
+ * @returns {boolean}
237
+ */
238
+ addMesh(mesh) {
239
+ if (this.hasMesh(mesh)) {
240
+ // already exists
241
+ return false;
242
+ }
136
243
 
137
- mesh.geo_bvh = this.obtainGeometryBVH(geo);
244
+ mesh.bvh = this.obtainGeometryBVH(mesh.geometry);
138
245
 
139
- mesh.transform = transform;
246
+ mesh.update_bounds();
140
247
 
141
248
  const bvh = this.bvh_top_level;
142
249
 
143
250
  const bvh_node_id = bvh.allocate_node();
144
251
 
145
- mesh.__bvh_node_id = bvh_node_id;
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);
252
+ this.#mesh_bvh_nodes.set(mesh, bvh_node_id);
161
253
 
162
254
  bvh.node_set_aabb(
163
255
  bvh_node_id,
164
- aabb_t
256
+ mesh.aabb
165
257
  );
258
+
166
259
  bvh.node_set_user_data(
167
260
  bvh_node_id,
168
261
  mesh.id
@@ -170,6 +263,49 @@ export class PathTracedScene {
170
263
  bvh.insert_leaf(bvh_node_id);
171
264
 
172
265
  this.meshes.set(mesh.id, mesh);
266
+
267
+
268
+ return true;
269
+ }
270
+
271
+ /**
272
+ *
273
+ * @param {PathTracedMesh} mesh
274
+ * @returns {boolean}
275
+ */
276
+ removeMesh(mesh) {
277
+
278
+ if (!this.hasMesh(mesh)) {
279
+ return false;
280
+ }
281
+
282
+ const node_id = this.#mesh_bvh_nodes.get(mesh);
283
+
284
+ this.#mesh_bvh_nodes.delete(mesh);
285
+
286
+ this.bvh_top_level.remove_leaf(node_id);
287
+ this.bvh_top_level.release_node(node_id);
288
+
289
+ return true;
290
+ }
291
+
292
+ /**
293
+ *
294
+ * @param {THREE.BufferGeometry} geometry
295
+ * @param {THREE.Material} material
296
+ * @param {mat4|number[]} transform
297
+ */
298
+ createMesh(geometry, material, transform) {
299
+ const standard_material = this.#material_cache.getOrCompute(material, DEFAULT_CONVERTER.convert, DEFAULT_CONVERTER);
300
+
301
+ const mesh = new PathTracedMesh();
302
+ mesh.geometry = geometry;
303
+
304
+ mesh.material = standard_material;
305
+
306
+ mesh.transform = transform;
307
+
308
+ this.addMesh(mesh);
173
309
  }
174
310
 
175
311
  /**
@@ -205,59 +341,52 @@ export class PathTracedScene {
205
341
  /**
206
342
  *
207
343
  * @param {number[]} out
208
- * @param {number[]} ray
344
+ * @param {number[]|Ray3} ray
209
345
  * @param {number} min_distance
210
346
  * @param {number} max_distance
211
- * @return {number}
347
+ * @return {number} distance to contact, or -1 if no contact found
212
348
  */
213
349
  trace(out, ray, min_distance, max_distance) {
350
+
214
351
  const bvh = this.bvh_top_level;
215
352
 
216
- const hit_count = bvh_query_leaves_ray(
353
+ const ray_origin_x = ray[0];
354
+ const ray_origin_y = ray[1];
355
+ const ray_origin_z = ray[2];
356
+
357
+ const ray_direction_x = ray[3];
358
+ const ray_direction_y = ray[4];
359
+ const ray_direction_z = ray[5];
360
+
361
+
362
+ const hit_count = bvh_query_user_data_ray_segment(
217
363
  bvh, bvh.root,
218
- temp_ray_results, 0,
219
- ray[0], ray[1], ray[2],
220
- ray[3], ray[4], ray[5]
364
+ scratch_uint32_array, 0,
365
+ ray_origin_x, ray_origin_y, ray_origin_z,
366
+ ray_direction_x, ray_direction_y, ray_direction_z,
367
+ min_distance, max_distance
221
368
  );
222
369
 
223
370
  let nearest_hit_distance = max_distance;
224
- let nearest_mesh = null;
225
-
226
371
 
227
372
  for (let i = 0; i < hit_count; i++) {
228
- const node = temp_ray_results[i];
229
373
 
230
- bvh.node_get_aabb(node, tmp_0);
231
-
232
- if (aabb3_unsigned_distance_sqr_to_point(
233
- tmp_0[0], tmp_0[1], tmp_0[2],
234
- tmp_0[3], tmp_0[4], tmp_0[5],
235
- ray[0], ray[1], ray[2]
236
- ) > nearest_hit_distance * nearest_hit_distance) {
237
- // bounds of the mesh are too far
238
- continue;
239
- }
240
-
241
- const node_user_data = bvh.node_get_user_data(node);
374
+ const node_user_data = scratch_uint32_array[i];
242
375
 
243
376
  const mesh = this.meshes.get(node_user_data);
244
377
 
245
- const distance_to_hit = mesh.hit(tmp_0, ray, min_distance, nearest_hit_distance);
378
+ const distance_to_hit = mesh.hit(out, ray, min_distance, nearest_hit_distance);
246
379
 
247
380
  if (distance_to_hit >= 0) {
248
381
  // since raycast in leaf nodes is already bound by maximum distance, any hit we get is necessarily a closer hit than before
249
382
  nearest_hit_distance = distance_to_hit;
250
- nearest_mesh = mesh;
251
-
252
- array_copy(tmp_0, 0, out, 0, 11);
253
383
  }
254
384
  }
255
385
 
256
386
  if (nearest_hit_distance !== max_distance) {
257
387
 
258
- // out[6] = nearest_mesh;
259
-
260
388
  return nearest_hit_distance;
389
+
261
390
  }
262
391
 
263
392
  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 "../../../../core/math/max2.js";
2
- import { min2 } from "../../../../core/math/min2.js";
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
@@ -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"}