@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
@@ -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":"AA8IA;IAQI;;;OAGG;IACH,eAFW,KAAK,GAAC,MAAM,EAAE,QAIxB;IAGG;;;;OAIG;IACH,cAAsB;IAEtB;;;;OAIG;IACH,mBAAsB;IAEtB;;;;OAIG;IACH,yBAA4B;IAE5B;;;;OAIG;IACH,6BAAgC;IAGhC;;;;OAIG;IACH,yBAAyB;IAG7B;;;OAGG;IACH,gBAFW,MAAM,cAAc,QAiC9B;IAGD;;;;;;;OAOG;IACH,gBANW,MAAM,EAAE,OACR,MAAM,EAAE,gBACR,MAAM,gBACN,MAAM,GACJ,MAAM,CA8ElB;;CACJ;sBAzTqB,wCAAwC"}
1
+ {"version":3,"file":"BufferedGeometryBVH.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js"],"names":[],"mappings":"AAwBA;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,CAyElB;;CACJ;sBAzMqB,wCAAwC"}
@@ -1,15 +1,15 @@
1
- import { split_by_3 } from "../../../../core/binary/split_by_3.js";
2
1
  import { BVH } 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 { bvh_query_user_data_ray } from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_ray.js";
3
+ import { bvh_query_user_data_ray_segment } from "../../../../core/bvh2/bvh3/query/bvh_query_user_data_ray_segment.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";
8
6
 
9
7
  import {
10
8
  computeTriangleRayIntersectionBarycentricGeometry
11
9
  } from "../../../../core/geom/3d/triangle/computeTriangleRayIntersectionBarycentricGeometry.js";
12
- import { v3_distance_sqr } from "../../../../core/geom/vec3/v3_distance_sqr.js";
10
+ import Vector4 from "../../../../core/geom/Vector4.js";
11
+ import { computeBoundingSphereFromVertexData } from "../../geometry/computeBoundingSphereFromVertexData.js";
12
+ import { construct_ray_hit_from_geometry } from "./geometry/construct_ray_hit_from_geometry.js";
13
13
 
14
14
  /**
15
15
  *
@@ -22,124 +22,6 @@ const scratch_uint32_array = new Uint32Array(4096);
22
22
  */
23
23
  const v3_scratch_0 = [];
24
24
 
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
25
  export class BufferedGeometryBVH {
144
26
  /**
145
27
  * @type {Uint32Array}
@@ -148,6 +30,16 @@ export class BufferedGeometryBVH {
148
30
 
149
31
  #bounds = new AABB3()
150
32
 
33
+ #bounds_sphere = new Float32Array(4);
34
+
35
+
36
+ /**
37
+ *
38
+ * @type {BVH}
39
+ * @private
40
+ */
41
+ #bvh = new BVH();
42
+
151
43
  /**
152
44
  *
153
45
  * @param {AABB3|number[]} out
@@ -157,12 +49,6 @@ export class BufferedGeometryBVH {
157
49
  }
158
50
 
159
51
  constructor() {
160
- /**
161
- *
162
- * @type {BVH}
163
- * @private
164
- */
165
- this.__bvh = new BVH();
166
52
 
167
53
  /**
168
54
  *
@@ -215,7 +101,7 @@ export class BufferedGeometryBVH {
215
101
 
216
102
  this.#morton_codes = new Uint32Array(this.__triangle_count);
217
103
 
218
- const bvh = this.__bvh;
104
+ const bvh = this.#bvh;
219
105
 
220
106
  ebvh_build_for_geometry_morton(
221
107
  bvh,
@@ -229,11 +115,16 @@ export class BufferedGeometryBVH {
229
115
 
230
116
  // remove any extra unused space
231
117
  bvh.trim();
118
+
119
+ const r = new Vector4();
120
+ computeBoundingSphereFromVertexData(array_positions, r);
121
+
122
+ r.toArray(this.#bounds_sphere);
232
123
  }
233
124
 
234
125
 
235
126
  /**
236
- *
127
+ * NOTE: raycast is performed in local coordinate space
237
128
  * @param {number[]} output
238
129
  * @param {number[]} ray
239
130
  * @param {number} min_distance
@@ -253,14 +144,14 @@ export class BufferedGeometryBVH {
253
144
  const direction_y = ray[4];
254
145
  const direction_z = ray[5];
255
146
 
256
- const bvh = this.__bvh;
147
+ const bvh = this.#bvh;
257
148
 
258
- // TODO we can unify BVH traversal with ray checks to reduce number of checks
259
- const count = bvh_query_user_data_ray(
149
+ const count = bvh_query_user_data_ray_segment(
260
150
  bvh, bvh.root,
261
151
  scratch_uint32_array, 0,
262
152
  origin_x, origin_y, origin_z,
263
- direction_x, direction_y, direction_z
153
+ direction_x, direction_y, direction_z,
154
+ min_distance, max_distance
264
155
  );
265
156
 
266
157
  if (count === 0) {
@@ -268,19 +159,13 @@ export class BufferedGeometryBVH {
268
159
  return -1;
269
160
  }
270
161
 
271
- let best_t = max_distance;
162
+
163
+ let nearest_hit_distance = max_distance;
272
164
 
273
165
  let best_index = -1;
274
166
  let best_u = 0;
275
167
  let best_v = 0;
276
168
 
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
-
283
-
284
169
  // check triangles found via BVH
285
170
  for (let i = 0; i < count; i++) {
286
171
  const triangle_index = scratch_uint32_array[i];
@@ -299,22 +184,23 @@ export class BufferedGeometryBVH {
299
184
 
300
185
  const t = v3_scratch_0[0];
301
186
 
302
- if (t < best_t && t > min_distance) {
303
- best_t = t;
187
+ if (t < nearest_hit_distance && t > min_distance) {
188
+ nearest_hit_distance = t;
304
189
 
305
190
  best_index = triangle_index;
306
191
  best_u = v3_scratch_0[1];
307
192
  best_v = v3_scratch_0[2];
193
+
308
194
  }
309
195
  }
310
196
 
311
- if (best_t === max_distance) {
197
+ if (nearest_hit_distance === max_distance) {
312
198
  // no hit
313
199
  return -1;
314
200
  }
315
201
 
316
- construct_ray_hit(output, indices, positions, best_index, best_t, best_u, best_v);
202
+ construct_ray_hit_from_geometry(output, indices, positions, best_index, nearest_hit_distance, best_u, best_v);
317
203
 
318
- return best_t;
204
+ return nearest_hit_distance;
319
205
  }
320
- }
206
+ }
@@ -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
- geo_bvh: BufferedGeometryBVH | null;
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
- __transform_inverse: Float32Array;
19
- __transform: Float32Array;
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":"AAcA;IACI,YAAmB;IAIf;;;OAGG;IACH,SAFU,sBAAoB,IAAI,CAEf;IAEnB;;;OAGG;IACH,UAFU,MAAM,cAAc,GAAC,IAAI,CAEf;IAEpB;;;OAGG;IACH,UAFU,mBAAiB,IAAI,CAEX;IAIpB,kCAA0D;IAC1D,0BAAuD;IACvD,8BAA8B;IAE9B;;;OAGG;IACH,IAFU,MAAM,CAEW;IAG/B,iCAgBC;IAED,8BAEC;IAED;;;;;;;OAOG;IACH,SANW,MAAM,EAAE,OACR,MAAM,EAAE,gBACR,MAAM,gBACN,MAAM,GACJ,MAAM,CAuDlB;CACJ;sBApIqB,wCAAwC"}
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 { v3_shift_along_direction } from "../../../../core/geom/vec3/v3_shift_along_direction.js";
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
- constructor() {
19
-
20
- /**
21
- *
22
- * @type {BufferedGeometryBVH|null}
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
- // precompute scaling factor for rays
56
- const m4 = this.__transform_inverse;
40
+ /**
41
+ *
42
+ * @type {THREE.BufferGeometry|null}
43
+ */
44
+ geometry = null;
57
45
 
58
- const scale_x = Math.hypot(m4[0], m4[1], m4[2]);
59
- const scale_y = Math.hypot(m4[4], m4[5], m4[6]);
60
- const scale_z = Math.hypot(m4[8], m4[9], m4[10]);
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
- this.__local_scale_inverse = Math.max(scale_x, scale_y, scale_z);
83
+ set transform(m) {
84
+ array_copy(m, 0, this.#transform, 0, 16);
85
+
86
+ mat4.invert(this.#transform_inverse, m);
63
87
 
64
- // get bounds
65
- this.geo_bvh.getBounds(this.aabb);
66
- this.aabb.applyMatrix4(m);
88
+ if (this.bvh !== null) {
89
+ this.update_bounds();
90
+ }
67
91
  }
68
92
 
69
93
  get transform() {
70
- return this.__transform;
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.__transform_inverse;
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,11 +117,11 @@ export class PathTracedMesh {
94
117
 
95
118
  if (max_distance !== Infinity) {
96
119
  // compute position of point at max_distance along the ray
97
- v3_shift_along_direction(
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],
101
- max_distance
124
+ max_distance-min_distance
102
125
  );
103
126
 
104
127
  // move far point into local coordinate space
@@ -111,11 +134,11 @@ export class PathTracedMesh {
111
134
  );
112
135
  }
113
136
 
114
- let distance_to_hit = this.geo_bvh.raycast(out, local_ray, 0, max_distance_local);
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.__transform);
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 {THREE.BufferGeometry} geo
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
- addMesh(geo: THREE.BufferGeometry, material: THREE.Material, transform: mat4 | number[]): void;
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":"AA8BA;IAGI;;;OAGG;IACH,eAFU,GAAG,CAEa;IAE1B;;;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;IAatB;;;;OAIG;IACH,6BAA6C;IAE7C,iBAGC;IAED,uBAMC;IAED;;;;OAIG;IACH,uBAHW,MAAM,cAAc,GACnB,mBAAmB,CAmB9B;IAED;;;OAGG;IACH,gBAFW,aAAa,QAMvB;IAED;;;;;OAKG;IACH,aAJW,MAAM,cAAc,YACpB,MAAM,QAAQ,aACd,OAAK,MAAM,EAAE,QA8CvB;IAED;;;;OAIG;IACH,qBAHW,MAAM,EAAE,OACR,MAAM,EAAE,QAyBlB;IAED;;;;;;;OAOG;IACH,WANW,MAAM,EAAE,OACR,MAAM,EAAE,gBACR,MAAM,gBACN,MAAM,GACL,MAAM,CAqDjB;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;oBA7VmB,mCAAmC;+BAkBxB,qBAAqB;8BALtB,kDAAkD;oCAE5C,0BAA0B"}
1
+ {"version":3,"file":"PathTracedScene.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/PathTracedScene.js"],"names":[],"mappings":"AA6CA;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,CA8CjB;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;oBA9d8B,mCAAmC;+BAiBnC,qBAAqB;8BAJtB,kDAAkD;oCAC5C,0BAA0B"}