@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
@@ -0,0 +1,79 @@
1
+ import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../SCRATCH_UINT32_TRAVERSAL_STACK.js";
2
+
3
+ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
4
+
5
+ /**
6
+ * @template T
7
+ * @param {T[]} data
8
+ * @param {Map<T,number>} lookup
9
+ * @param {number} start
10
+ * @param {number} end
11
+ */
12
+ export function array_quick_sort_by_lookup_map(
13
+ data,
14
+ lookup,
15
+ start, end
16
+ ) {
17
+ if (start >= end) {
18
+ // section of 0 size, nothing to sort
19
+ return;
20
+ }
21
+
22
+ const stack_frame = start.pointer;
23
+ let stackPointer = stack_frame;
24
+
25
+ let i, j;
26
+
27
+ stack[stackPointer++] = start;
28
+ stack[stackPointer++] = end;
29
+
30
+ while (stackPointer > stack_frame) {
31
+ stackPointer -= 2;
32
+
33
+ const right = stack[stackPointer + 1];
34
+ const left = stack[stackPointer];
35
+
36
+ i = left;
37
+ j = right;
38
+
39
+ const pivotIndex = (left + right) >> 1;
40
+
41
+ const pivot = data[pivotIndex];
42
+ const pivot_score = lookup.get(pivot);
43
+
44
+ /* partition */
45
+ while (i <= j) {
46
+ while (lookup.get(data[i]) < pivot_score) {
47
+ i++;
48
+ }
49
+
50
+ while (lookup.get(data[j]) > pivot_score) {
51
+ j--;
52
+ }
53
+
54
+ if (i <= j) {
55
+
56
+ if (i !== j) {
57
+ //do swap
58
+ const tmp = data[i];
59
+ data[i] = data[j];
60
+ data[j] = tmp;
61
+
62
+ }
63
+
64
+ i++;
65
+ j--;
66
+ }
67
+ }
68
+
69
+ /* recursion */
70
+ if (left < j) {
71
+ stack[stackPointer++] = left;
72
+ stack[stackPointer++] = j;
73
+ }
74
+ if (i < right) {
75
+ stack[stackPointer++] = i;
76
+ stack[stackPointer++] = right;
77
+ }
78
+ }
79
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @param {number[]|Uint32Array} data
3
+ * @param {number[]|Uint32Array} lookup
4
+ * @param {number} start
5
+ * @param {number} end
6
+ */
7
+ export function array_quick_sort_by_lookup_uint(data: number[] | Uint32Array, lookup: number[] | Uint32Array, start: number, end: number): void;
8
+ //# sourceMappingURL=array_quick_sort_by_lookup_uint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array_quick_sort_by_lookup_uint.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_quick_sort_by_lookup_uint.js"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,sDALW,MAAM,EAAE,GAAC,WAAW,UACpB,MAAM,EAAE,GAAC,WAAW,SACpB,MAAM,OACN,MAAM,QAqEhB"}
@@ -8,7 +8,7 @@ const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
8
8
  * @param {number} start
9
9
  * @param {number} end
10
10
  */
11
- export function array_quick_sort_by_lookup(
11
+ export function array_quick_sort_by_lookup_uint(
12
12
  data,
13
13
  lookup,
14
14
  start, end
@@ -10,7 +10,7 @@ import { array_swap_one } from "./array_swap_one.js";
10
10
  export function array_shuffle(random, array) {
11
11
  const n = array.length;
12
12
 
13
- for (let source_index = 0; source_index < n; source_index++) {
13
+ for (let source_index = 0; source_index < n; ++source_index) {
14
14
  const target_index = randomIntegerBetween(random, 0, n - (source_index + 1));
15
15
 
16
16
  if (target_index === source_index) {
@@ -1 +1 @@
1
- {"version":3,"file":"array_swap_one.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_swap_one.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,sDAHW,MAAM,UACN,MAAM,QAOhB"}
1
+ {"version":3,"file":"array_swap_one.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_swap_one.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,sDAHW,MAAM,UACN,MAAM,QAWhB"}
@@ -1,3 +1,5 @@
1
+ import { assert } from "../../assert.js";
2
+
1
3
  /**
2
4
  * @template T
3
5
  * @param {T[]} array
@@ -5,6 +7,10 @@
5
7
  * @param {number} index1
6
8
  */
7
9
  export function array_swap_one(array, index0, index1) {
10
+ assert.isArrayLike(array, 'array');
11
+ assert.isNonNegativeInteger(index0, 'index0');
12
+ assert.isNonNegativeInteger(index1, 'index1');
13
+
8
14
  const t = array[index0];
9
15
 
10
16
  array[index0] = array[index1];
@@ -337,11 +337,11 @@ export class HashMap {
337
337
  return true;
338
338
  }
339
339
 
340
- assert.equal(record.hash, this.#build_key_hash(record.key), `Key hash has diverged for key ${record.key}, likely key was mutated or hash function is unstable`);
340
+ // assert.equal(record.hash, this.#build_key_hash(record.key), `Key hash has diverged for key ${record.key}, likely key was mutated or hash function is unstable`);
341
341
 
342
342
  const result = this.keyEqualityFunction(record.key, key);
343
343
 
344
- assert.isBoolean(result, `result(a=${record.key},b=${key})`);
344
+ // assert.isBoolean(result, `result(a=${record.key},b=${key})`);
345
345
 
346
346
  return result;
347
347
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../../../../src/core/events/signal/Signal.js"],"names":[],"mappings":"AAulBA;;;;;;GAMG;AACH,yDALW,aAAa,EAAE,+BAGb,MAAM,CAoBlB;AAED;;;;;;GAMG;AACH,mEALW,aAAa,EAAE,0BAGb,MAAM,CAclB;AAiDD;;;;GAIG;AACH,2CAHW,aAAa,EAAE,sBA8BzB;AAnsBD;;;;GAIG;AACH;IACI;;;OAGG;IACH,iBAAc;IAEd;;;;OAIG;IACH,cAAU;IAWV;;;OAGG;IACH,yBAEC;IAfD;;;OAGG;IACH,sBAEC;IAYD;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,SAClB,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,OAAO,CAInB;IAGD;;;;;OAKG;IACH,4CAFa,OAAO,CAQnB;IAED,aAEC;IAED,eAEC;IAED;;;OAGG;IACH,eAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,yCAQC;IAED;;;;OAIG;IACH,sCAYC;IAED;;;;;OAKG;IACH,oCAFa,OAAO,CAUnB;IAED;;;;;;OAMG;IACH,kBAGC;IAED;;;OAGG;IACH,+BAQC;IAED;;;OAGG;IACH,cA4CC;IAED;;;;OAIG;IACH,sBA6CC;IAED;;;;OAIG;IACH,4BA4CC;IAED;;;;;OAKG;IACH,oCA4CC;IAED;;;;;;OAMG;IACH,4CA4CC;IAED;;;;;;;;OAQG;IACH,4DA4CC;IAED;;;;;;;;;;OAUG;IACH,4EA4CC;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,MAAM,CAalB;IAIL;;;OAGG;IACH,mBAFU,OAAO,CAEQ;CAPxB;;8BArkBiD,oBAAoB"}
1
+ {"version":3,"file":"Signal.d.ts","sourceRoot":"","sources":["../../../../../src/core/events/signal/Signal.js"],"names":[],"mappings":"AAglBA;;;;;;GAMG;AACH,yDALW,aAAa,EAAE,+BAGb,MAAM,CAoBlB;AAED;;;;;;GAMG;AACH,mEALW,aAAa,EAAE,0BAGb,MAAM,CAelB;AAuDD;;;;GAIG;AACH,2CAHW,aAAa,EAAE,sBA8BzB;AA1sBD;;;;GAIG;AACH;IACI;;;OAGG;IACH,iBAAc;IAEd;;;;OAIG;IACH,cAAU;IAWV;;;OAGG;IACH,yBAEC;IAfD;;;OAGG;IACH,sBAEC;IAYD;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,GAChB,IAAI,CAIhB;IAED;;;;OAIG;IACH,gBAHW,MAAM;;KAAY,SAClB,OAAO,QAQjB;IAED;;;;OAIG;IACH,cAHW,MAAM;;KAAY,GAChB,OAAO,CAInB;IAGD;;;;;OAKG;IACH,4CAFa,OAAO,CAQnB;IAED,aAEC;IAED,eAEC;IAED;;;OAGG;IACH,eAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,yCAQC;IAED;;;;OAIG;IACH,sCAYC;IAED;;;;;OAKG;IACH,oCAFa,OAAO,CAUnB;IAED;;;;;;OAMG;IACH,kBAGC;IAED;;;OAGG;IACH,+BAQC;IAED;;;OAGG;IACH,cA4CC;IAED;;;;OAIG;IACH,sBA6CC;IAED;;;;OAIG;IACH,4BA4CC;IAED;;;;;OAKG;IACH,oCA4CC;IAED;;;;;;OAMG;IACH,4CA4CC;IAED;;;;;;;;OAQG;IACH,4DA4CC;IAED;;;;;;;;;;OAUG;IACH,4EA4CC;IAED;;;;OAIG;IACH,aAHW,MAAM,GACJ,MAAM,CAalB;IAIL;;;OAGG;IACH,mBAFU,OAAO,CAEQ;CAPxB;;8BArkBiD,oBAAoB"}
@@ -1,10 +1,3 @@
1
- /**
2
- *
3
- * @author Alex Goldring
4
- * @copyright Alex Goldring 2014
5
- */
6
-
7
-
8
1
  import { assert } from "../../assert.js";
9
2
  import { SignalFlags } from "./SignalFlags.js";
10
3
  import { SignalHandler, SignalHandlerFlags } from "./SignalHandler.js";
@@ -635,11 +628,12 @@ export function findSignalHandlerIndexByHandleAndContext(handlers, f, ctx) {
635
628
  const l = handlers.length;
636
629
 
637
630
  for (let i = 0; i < l; i++) {
638
- const signalHandler = handlers[i];
631
+ const handler = handlers[i];
639
632
 
640
- if (signalHandler.handle === f && signalHandler.context === ctx) {
633
+ if (handler.handle === f && handler.context === ctx) {
641
634
  return i;
642
635
  }
636
+
643
637
  }
644
638
 
645
639
  return -1;
@@ -672,7 +666,7 @@ function removeHandlerByHandler(signal, h) {
672
666
  */
673
667
  function removeHandlerByHandlerAndContext(signal, h, ctx) {
674
668
  const handlers = signal.handlers;
675
- let i = findSignalHandlerIndexByHandleAndContext(handlers, h, ctx);
669
+ const i = findSignalHandlerIndexByHandleAndContext(handlers, h, ctx);
676
670
 
677
671
  if (i >= 0) {
678
672
  handlers.splice(i, 1);
@@ -682,6 +676,12 @@ function removeHandlerByHandlerAndContext(signal, h, ctx) {
682
676
  return false;
683
677
  }
684
678
 
679
+ /**
680
+ *
681
+ * @param {function} f
682
+ * @param {*} context
683
+ * @param {Array} args
684
+ */
685
685
  function dispatchCallback(f, context, args) {
686
686
  assert.isFunction(f, 'f');
687
687
 
@@ -1 +1 @@
1
- {"version":3,"file":"compute_triangle_area_2d.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/compute_triangle_area_2d.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,6CARW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAYlB"}
1
+ {"version":3,"file":"compute_triangle_area_2d.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/compute_triangle_area_2d.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,6CARW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAclB"}
@@ -14,8 +14,10 @@ export function compute_triangle_area_2d(
14
14
  x2, y2
15
15
  ) {
16
16
 
17
- return 0.5 * (
18
- (x0 * y1 - y0 * x1) + (x1 * y2 - y1 * x2) + (x2 * y0 - y2 * x0)
19
- );
17
+ return (
18
+ (x0 * y1 - y0 * x1)
19
+ + (x1 * y2 - y1 * x2)
20
+ + (x2 * y0 - y2 * x0)
21
+ ) * 0.5;
20
22
 
21
23
  }
@@ -4,6 +4,12 @@
4
4
  export class Ray3 {
5
5
  origin: Vector3;
6
6
  direction: Vector3;
7
+ get 0(): number;
8
+ get 1(): number;
9
+ get 2(): number;
10
+ get 3(): number;
11
+ get 4(): number;
12
+ get 5(): number;
7
13
  /**
8
14
  *
9
15
  * @param {number[]|mat4|Float32Array} m4
@@ -1 +1 @@
1
- {"version":3,"file":"Ray3.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/3d/Ray3.js"],"names":[],"mappings":"AAEA;;GAEG;AACH;IACI,gBAAsB;IACtB,mBAAyB;IAEzB;;;OAGG;IACH,iBAFW,MAAM,EAAE,UAAM,YAAY,QAKpC;IAED;;;OAGG;IACH,YAFW,IAAI,QAKd;CACJ;oBA1BmB,eAAe"}
1
+ {"version":3,"file":"Ray3.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/3d/Ray3.js"],"names":[],"mappings":"AAEA;;GAEG;AACH;IACI,gBAAsB;IACtB,mBAAyB;IAEzB,gBAEC;IAED,gBAEC;IAED,gBAEC;IAED,gBAEC;IAED,gBAEC;IAED,gBAEC;IAED;;;OAGG;IACH,iBAFW,MAAM,EAAE,UAAM,YAAY,QAKpC;IAED;;;OAGG;IACH,YAFW,IAAI,QAKd;CACJ;oBAlDmB,eAAe"}
@@ -7,6 +7,30 @@ export class Ray3 {
7
7
  origin = new Vector3()
8
8
  direction = new Vector3()
9
9
 
10
+ get 0() {
11
+ return this.origin.x
12
+ }
13
+
14
+ get 1() {
15
+ return this.origin.y
16
+ }
17
+
18
+ get 2() {
19
+ return this.origin.z
20
+ }
21
+
22
+ get 3() {
23
+ return this.direction.x
24
+ }
25
+
26
+ get 4() {
27
+ return this.direction.y
28
+ }
29
+
30
+ get 5() {
31
+ return this.direction.z
32
+ }
33
+
10
34
  /**
11
35
  *
12
36
  * @param {number[]|mat4|Float32Array} m4
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Distance of the nearest point along the plane normal from the plane
3
+ * @param {number} plane_normal_x
4
+ * @param {number} plane_normal_y
5
+ * @param {number} plane_normal_z
6
+ * @param {number} plane_constant
7
+ * @param {number} _x0
8
+ * @param {number} _y0
9
+ * @param {number} _z0
10
+ * @param {number} _x1
11
+ * @param {number} _y1
12
+ * @param {number} _z1
13
+ * @returns {number}
14
+ */
15
+ export function aabb3_compute_distance_above_plane_min(plane_normal_x: number, plane_normal_y: number, plane_normal_z: number, plane_constant: number, _x0: number, _y0: number, _z0: number, _x1: number, _y1: number, _z1: number): number;
16
+ //# sourceMappingURL=aabb3_compute_distance_above_plane_min.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aabb3_compute_distance_above_plane_min.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_min.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,uEAZW,MAAM,kBACN,MAAM,kBACN,MAAM,kBACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,GACJ,MAAM,CAelB"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Distance of the nearest point along the plane normal from the plane
3
+ * @param {number} plane_normal_x
4
+ * @param {number} plane_normal_y
5
+ * @param {number} plane_normal_z
6
+ * @param {number} plane_constant
7
+ * @param {number} _x0
8
+ * @param {number} _y0
9
+ * @param {number} _z0
10
+ * @param {number} _x1
11
+ * @param {number} _y1
12
+ * @param {number} _z1
13
+ * @returns {number}
14
+ */
15
+ export function aabb3_compute_distance_above_plane_min(
16
+ plane_normal_x, plane_normal_y, plane_normal_z, plane_constant,
17
+ _x0, _y0, _z0,
18
+ _x1, _y1, _z1
19
+ ) {
20
+
21
+ // pick a corner point that is the closest along the plane normal
22
+ const px = plane_normal_x > 0 ? _x0 : _x1;
23
+ const py = plane_normal_y > 0 ? _y0 : _y1;
24
+ const pz = plane_normal_z > 0 ? _z0 : _z1;
25
+
26
+ // dot(v4,v4) inlined for speed
27
+ return plane_constant + plane_normal_x * px + plane_normal_y * py + plane_normal_z * pz;
28
+ }
29
+
@@ -3,7 +3,7 @@
3
3
  * @param {AABB3} result
4
4
  * @param {number[]|ArrayLike<number>} input
5
5
  * @param {number} input_length
6
- * @param {ArrayLike<number>|number[]|Float32Array} e 4x4 transformation matrix
6
+ * @param {ArrayLike<number>|number[]|Float32Array} matrix 4x4 transformation matrix
7
7
  */
8
- export function aabb3_from_v3_array_transformed(result: AABB3, input: number[] | ArrayLike<number>, input_length: number, e: ArrayLike<number> | number[] | Float32Array): void;
8
+ export function aabb3_from_v3_array_transformed(result: AABB3, input: number[] | ArrayLike<number>, input_length: number, matrix: ArrayLike<number> | number[] | Float32Array): void;
9
9
  //# sourceMappingURL=aabb3_from_v3_array_transformed.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"aabb3_from_v3_array_transformed.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,sEAJW,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,gBAC1B,MAAM,KACN,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,QA8BjD"}
1
+ {"version":3,"file":"aabb3_from_v3_array_transformed.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_from_v3_array_transformed.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,sEAJW,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,gBAC1B,MAAM,UACN,UAAU,MAAM,CAAC,GAAC,MAAM,EAAE,GAAC,YAAY,QA8BjD"}
@@ -1,14 +1,14 @@
1
- import { min2 } from "../../../math/min2.js";
2
1
  import { max2 } from "../../../math/max2.js";
2
+ import { min2 } from "../../../math/min2.js";
3
3
 
4
4
  /**
5
5
  *
6
6
  * @param {AABB3} result
7
7
  * @param {number[]|ArrayLike<number>} input
8
8
  * @param {number} input_length
9
- * @param {ArrayLike<number>|number[]|Float32Array} e 4x4 transformation matrix
9
+ * @param {ArrayLike<number>|number[]|Float32Array} matrix 4x4 transformation matrix
10
10
  */
11
- export function aabb3_from_v3_array_transformed(result, input, input_length, e) {
11
+ export function aabb3_from_v3_array_transformed(result, input, input_length, matrix) {
12
12
  let x0 = Infinity;
13
13
  let y0 = Infinity;
14
14
  let z0 = Infinity;
@@ -22,9 +22,9 @@ export function aabb3_from_v3_array_transformed(result, input, input_length, e)
22
22
  const y = input[i + 1];
23
23
  const z = input[i + 2];
24
24
 
25
- const _x = e[0] * x + e[4] * y + e[8] * z + e[12];
26
- const _y = e[1] * x + e[5] * y + e[9] * z + e[13];
27
- const _z = e[2] * x + e[6] * y + e[10] * z + e[14];
25
+ const _x = matrix[0] * x + matrix[4] * y + matrix[8] * z + matrix[12];
26
+ const _y = matrix[1] * x + matrix[5] * y + matrix[9] * z + matrix[13];
27
+ const _z = matrix[2] * x + matrix[6] * y + matrix[10] * z + matrix[14];
28
28
 
29
29
  x0 = min2(_x, x0);
30
30
  y0 = min2(_y, y0);
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @see Ray Tracing Gems II, Chapter 2 "RAY AXIS-ALIGNED BOUNDING BOX INTERSECTION"
3
+ * @param {number} x0
4
+ * @param {number} y0
5
+ * @param {number} z0
6
+ * @param {number} x1
7
+ * @param {number} y1
8
+ * @param {number} z1
9
+ * @param {number} origin_x
10
+ * @param {number} origin_y
11
+ * @param {number} origin_z
12
+ * @param {number} direction_x
13
+ * @param {number} direction_y
14
+ * @param {number} direction_z
15
+ * @param {number} min_distance
16
+ * @param {number} max_distance
17
+ * @returns {boolean}
18
+ * @returns {boolean}
19
+ */
20
+ export function aabb3_intersects_ray_segment(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, origin_x: number, origin_y: number, origin_z: number, direction_x: number, direction_y: number, direction_z: number, min_distance: number, max_distance: number): boolean;
21
+ //# sourceMappingURL=aabb3_intersects_ray_segment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aabb3_intersects_ray_segment.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/aabb/aabb3_intersects_ray_segment.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AACH,iDAjBW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,YACN,MAAM,YACN,MAAM,YACN,MAAM,eACN,MAAM,eACN,MAAM,eACN,MAAM,gBACN,MAAM,gBACN,MAAM,GACJ,OAAO,CA+CnB"}
@@ -0,0 +1,67 @@
1
+ import { max2 } from "../../../math/max2.js";
2
+ import { min2 } from "../../../math/min2.js";
3
+
4
+ /**
5
+ * @see Ray Tracing Gems II, Chapter 2 "RAY AXIS-ALIGNED BOUNDING BOX INTERSECTION"
6
+ * @param {number} x0
7
+ * @param {number} y0
8
+ * @param {number} z0
9
+ * @param {number} x1
10
+ * @param {number} y1
11
+ * @param {number} z1
12
+ * @param {number} origin_x
13
+ * @param {number} origin_y
14
+ * @param {number} origin_z
15
+ * @param {number} direction_x
16
+ * @param {number} direction_y
17
+ * @param {number} direction_z
18
+ * @param {number} min_distance
19
+ * @param {number} max_distance
20
+ * @returns {boolean}
21
+ * @returns {boolean}
22
+ */
23
+ export function aabb3_intersects_ray_segment(
24
+ x0, y0, z0,
25
+ x1, y1, z1,
26
+ origin_x, origin_y, origin_z,
27
+ direction_x, direction_y, direction_z,
28
+ min_distance, max_distance
29
+ ) {
30
+
31
+ // move aabb into ray space
32
+ const _x0 = x0 - origin_x;
33
+ const _y0 = y0 - origin_y;
34
+ const _z0 = z0 - origin_z;
35
+
36
+ const _x1 = x1 - origin_x;
37
+ const _y1 = y1 - origin_y;
38
+ const _z1 = z1 - origin_z;
39
+
40
+ const inv_direction_x = 1 / direction_x;
41
+ const inv_direction_y = 1 / direction_y;
42
+ const inv_direction_z = 1 / direction_z;
43
+
44
+ // Absolute distances to lower and upper box coordinates
45
+ const t_lower_x = _x0 * inv_direction_x;
46
+ const t_lower_y = _y0 * inv_direction_y;
47
+ const t_lower_z = _z0 * inv_direction_z;
48
+
49
+ const t_upper_x = _x1 * inv_direction_x;
50
+ const t_upper_y = _y1 * inv_direction_y;
51
+ const t_upper_z = _z1 * inv_direction_z;
52
+
53
+ // The four t-intervals (for x-/y-/z-slabs, and ray p(t))
54
+ const t_min_x = min2(t_lower_x, t_upper_x);
55
+ const t_min_y = min2(t_lower_y, t_upper_y);
56
+ const t_min_z = min2(t_lower_z, t_upper_z);
57
+
58
+ const t_max_x = max2(t_lower_x, t_upper_x);
59
+ const t_max_y = max2(t_lower_y, t_upper_y);
60
+ const t_max_z = max2(t_lower_z, t_upper_z);
61
+
62
+ // Easy to remember: ``max of mins, and min of maxes''
63
+ const t_box_min = Math.max(t_min_x, t_min_y, t_min_z, min_distance);
64
+ const t_box_max = Math.min(t_max_x, t_max_y, t_max_z, max_distance);
65
+
66
+ return t_box_min <= t_box_max;
67
+ }
@@ -21,8 +21,8 @@
21
21
  * @param {number[]} res
22
22
  * @param {number[]|Float32Array|mat4} m4
23
23
  * @param {number} a0 axis index
24
- * @param {number} a1
25
- * @param {number} a2
24
+ * @param {number} a1 axis index
25
+ * @param {number} a2 axis index
26
26
  */
27
27
  export function eulerAnglesFromMatrix(res: number[], m4: number[] | Float32Array | mat4, a0: number, a1: number, a2: number): void;
28
28
  //# sourceMappingURL=eulerAnglesFromMatrix.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"eulerAnglesFromMatrix.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/3d/eulerAnglesFromMatrix.js"],"names":[],"mappings":"AA6BA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,2CANW,MAAM,EAAE,MACR,MAAM,EAAE,GAAC,YAAY,OAAK,MAC1B,MAAM,MACN,MAAM,MACN,MAAM,QA6DhB"}
1
+ {"version":3,"file":"eulerAnglesFromMatrix.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/3d/eulerAnglesFromMatrix.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,2CANW,MAAM,EAAE,MACR,MAAM,EAAE,GAAC,YAAY,OAAK,MAC1B,MAAM,MACN,MAAM,MACN,MAAM,QA2EhB"}
@@ -1,10 +1,5 @@
1
- //
2
-
3
1
  import { v2_magnitude } from "../vec2/v2_magnitude.js";
4
2
 
5
- function atan2(a, b) {
6
- return Math.atan2(a, b);
7
- }
8
3
 
9
4
  /**
10
5
  *
@@ -17,15 +12,9 @@ function coeff(mat4, row_index, column_index) {
17
12
  return mat4[row_index + column_index * 4];
18
13
  }
19
14
 
20
- function sin(a) {
21
- return Math.sin(a);
22
- }
23
-
24
- function cos(a) {
25
- return Math.cos(a);
26
- }
27
-
28
- const EIGEN_PI = Math.PI;
15
+ const sin = Math.sin;
16
+ const cos = Math.cos;
17
+ const atan2 = Math.atan2;
29
18
 
30
19
  /**
31
20
  *
@@ -50,10 +39,14 @@ const EIGEN_PI = Math.PI;
50
39
  * @param {number[]} res
51
40
  * @param {number[]|Float32Array|mat4} m4
52
41
  * @param {number} a0 axis index
53
- * @param {number} a1
54
- * @param {number} a2
42
+ * @param {number} a1 axis index
43
+ * @param {number} a2 axis index
55
44
  */
56
- export function eulerAnglesFromMatrix(res, m4, a0, a1, a2) {
45
+ export function eulerAnglesFromMatrix(
46
+ res, m4,
47
+ a0, a1, a2
48
+ ) {
49
+
57
50
  const odd = ((a0 + 1) % 3 === a1) ? 0 : 1;
58
51
 
59
52
  const i = a0;
@@ -62,11 +55,12 @@ export function eulerAnglesFromMatrix(res, m4, a0, a1, a2) {
62
55
 
63
56
  if (a0 === a2) {
64
57
  res[0] = atan2(coeff(m4, j, i), coeff(m4, k, i));
65
- if ((odd && res[0] < 0) || ((!odd) && res[0] > 0)) {
58
+
59
+ if ((odd && res[0] < 0) || ((~odd) && res[0] > 0)) {
66
60
  if (res[0] > 0) {
67
- res[0] -= EIGEN_PI;
61
+ res[0] -= Math.PI;
68
62
  } else {
69
- res[0] += EIGEN_PI;
63
+ res[0] += Math.PI;
70
64
  }
71
65
  const s2 = v2_magnitude(coeff(m4, j, i), coeff(m4, k, i));
72
66
  res[1] = -atan2(s2, coeff(m4, i, i));
@@ -87,25 +81,34 @@ export function eulerAnglesFromMatrix(res, m4, a0, a1, a2) {
87
81
 
88
82
  const s1 = sin(res[0]);
89
83
  const c1 = cos(res[0]);
84
+
90
85
  res[2] = atan2(c1 * coeff(m4, j, k) - s1 * coeff(m4, k, k), c1 * coeff(m4, j, j) - s1 * coeff(m4, k, j));
86
+
91
87
  } else {
88
+
92
89
  res[0] = atan2(coeff(m4, j, k), coeff(m4, k, k));
90
+
93
91
  const c2 = v2_magnitude(coeff(m4, i, i), coeff(m4, i, j));
94
- if ((odd && res[0] < 0) || ((!odd) && res[0] > 0)) {
92
+
93
+ if ((odd && res[0] < 0) || ((~odd) && res[0] > 0)) {
95
94
  if (res[0] > 0) {
96
- res[0] -= EIGEN_PI;
95
+ res[0] -= Math.PI;
97
96
  } else {
98
- res[0] += EIGEN_PI;
97
+ res[0] += Math.PI;
99
98
  }
100
99
  res[1] = atan2(-coeff(m4, i, k), -c2);
101
- } else
100
+ } else {
102
101
  res[1] = atan2(-coeff(m4, i, k), c2);
102
+ }
103
+
103
104
  const s1 = sin(res[0]);
104
105
  const c1 = cos(res[0]);
106
+
105
107
  res[2] = atan2(s1 * coeff(m4, k, i) - c1 * coeff(m4, j, i), c1 * coeff(m4, j, j) - s1 * coeff(m4, k, j));
108
+
106
109
  }
107
110
 
108
- if (!odd) {
111
+ if (odd === 0) {
109
112
  // invert result
110
113
  res[0] = -res[0];
111
114
  res[1] = -res[1];
@@ -2,8 +2,8 @@
2
2
  * @param {number} x
3
3
  * @param {number} y
4
4
  * @param {number} z
5
- * @param {number[]} bounds
5
+ * @param {number[]|AABB3} bounds
6
6
  * @returns {number}
7
7
  */
8
- export function v3_morton_encode_bounded(x: number, y: number, z: number, bounds: number[]): number;
8
+ export function v3_morton_encode_bounded(x: number, y: number, z: number, bounds: number[] | AABB3): number;
9
9
  //# sourceMappingURL=v3_morton_encode_bounded.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"v3_morton_encode_bounded.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/v3_morton_encode_bounded.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,4CANW,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,EAAE,GACN,MAAM,CA0BlB"}
1
+ {"version":3,"file":"v3_morton_encode_bounded.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/morton/v3_morton_encode_bounded.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,4CANW,MAAM,KACN,MAAM,KACN,MAAM,UACN,MAAM,EAAE,QAAM,GACZ,MAAM,CA0BlB"}
@@ -4,7 +4,7 @@ import { mortonEncode_magicbits } from "./mortonEncode_magicbits.js";
4
4
  * @param {number} x
5
5
  * @param {number} y
6
6
  * @param {number} z
7
- * @param {number[]} bounds
7
+ * @param {number[]|AABB3} bounds
8
8
  * @returns {number}
9
9
  */
10
10
  export function v3_morton_encode_bounded(x, y, z, bounds) {
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @see A Survey of Efficient Representations for Independent Unit Vectors (Journal of Computer Graphics Techniques Vol. 3, No. 2, 2014) - page 13
3
3
  * @see https://gamedev.stackexchange.com/questions/169508/octahedral-impostors-octahedral-mapping
4
- * @param {number[]} output
4
+ * @param {number[]|Vector3} output
5
5
  * @param {number} output_offset
6
6
  * @param {number} x range [0,1]
7
7
  * @param {number} y range [0,1]
8
8
  */
9
- export function decode_octahedron_to_unit(output: number[], output_offset: number, x: number, y: number): void;
9
+ export function decode_octahedron_to_unit(output: number[] | Vector3, output_offset: number, x: number, y: number): void;
10
10
  //# sourceMappingURL=decode_octahedron_to_unit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decode_octahedron_to_unit.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,kDALW,MAAM,EAAE,iBACR,MAAM,KACN,MAAM,KACN,MAAM,QAsBhB"}
1
+ {"version":3,"file":"decode_octahedron_to_unit.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/normal/octahedron/decode_octahedron_to_unit.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,kDALW,MAAM,EAAE,UAAQ,iBAChB,MAAM,KACN,MAAM,KACN,MAAM,QAsBhB"}
@@ -3,7 +3,7 @@ import { sign_not_zero } from "../../../../math/sign_not_zero.js";
3
3
  /**
4
4
  * @see A Survey of Efficient Representations for Independent Unit Vectors (Journal of Computer Graphics Techniques Vol. 3, No. 2, 2014) - page 13
5
5
  * @see https://gamedev.stackexchange.com/questions/169508/octahedral-impostors-octahedral-mapping
6
- * @param {number[]} output
6
+ * @param {number[]|Vector3} output
7
7
  * @param {number} output_offset
8
8
  * @param {number} x range [0,1]
9
9
  * @param {number} y range [0,1]