@woosh/meep-engine 2.138.20 → 2.140.0

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 (584) hide show
  1. package/package.json +1 -1
  2. package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_aabb.d.ts +3 -3
  3. package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_aabb.d.ts.map +1 -1
  4. package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_aabb.js +4 -4
  5. package/src/core/collection/PairUint32Map.d.ts +100 -0
  6. package/src/core/collection/PairUint32Map.d.ts.map +1 -0
  7. package/src/core/collection/PairUint32Map.js +321 -0
  8. package/src/core/collection/Uint32Map.d.ts +119 -0
  9. package/src/core/collection/Uint32Map.d.ts.map +1 -0
  10. package/src/core/collection/Uint32Map.js +345 -0
  11. package/src/core/collection/array/array_shuffle.d.ts +10 -3
  12. package/src/core/collection/array/array_shuffle.d.ts.map +1 -1
  13. package/src/core/collection/array/array_shuffle.js +27 -22
  14. package/src/core/collection/heap/FibonacciHeap.d.ts +195 -0
  15. package/src/core/collection/heap/FibonacciHeap.d.ts.map +1 -0
  16. package/src/core/collection/heap/FibonacciHeap.js +586 -0
  17. package/src/core/collection/heap/Uint32Heap.js +1 -1
  18. package/src/core/collection/heap/Uint32Heap4.d.ts +169 -0
  19. package/src/core/collection/heap/Uint32Heap4.d.ts.map +1 -0
  20. package/src/core/collection/heap/Uint32Heap4.js +490 -0
  21. package/src/core/geom/3d/aabb/aabb3_transform_oriented.d.ts +30 -0
  22. package/src/core/geom/3d/aabb/aabb3_transform_oriented.d.ts.map +1 -0
  23. package/src/core/geom/3d/aabb/aabb3_transform_oriented.js +93 -0
  24. package/src/core/geom/3d/line/line3_closest_points_segment_segment.d.ts +27 -0
  25. package/src/core/geom/3d/line/line3_closest_points_segment_segment.d.ts.map +1 -0
  26. package/src/core/geom/3d/line/line3_closest_points_segment_segment.js +88 -0
  27. package/src/core/geom/3d/quaternion/quat3_to_matrix3.d.ts +54 -0
  28. package/src/core/geom/3d/quaternion/quat3_to_matrix3.d.ts.map +1 -0
  29. package/src/core/geom/3d/quaternion/quat3_to_matrix3.js +69 -0
  30. package/src/core/geom/3d/shape/AbstractShape3D.d.ts +24 -2
  31. package/src/core/geom/3d/shape/AbstractShape3D.d.ts.map +1 -1
  32. package/src/core/geom/3d/shape/AbstractShape3D.js +24 -1
  33. package/src/core/geom/3d/shape/BoxShape3D.d.ts +61 -0
  34. package/src/core/geom/3d/shape/BoxShape3D.d.ts.map +1 -0
  35. package/src/core/geom/3d/shape/BoxShape3D.js +158 -0
  36. package/src/core/geom/3d/shape/CapsuleShape3D.d.ts +11 -0
  37. package/src/core/geom/3d/shape/CapsuleShape3D.d.ts.map +1 -1
  38. package/src/core/geom/3d/shape/CapsuleShape3D.js +12 -0
  39. package/src/core/geom/3d/shape/HeightMapShape3D.d.ts +148 -0
  40. package/src/core/geom/3d/shape/HeightMapShape3D.d.ts.map +1 -0
  41. package/src/core/geom/3d/shape/HeightMapShape3D.js +451 -0
  42. package/src/core/geom/3d/shape/MeshShape3D.d.ts +210 -0
  43. package/src/core/geom/3d/shape/MeshShape3D.d.ts.map +1 -0
  44. package/src/core/geom/3d/shape/MeshShape3D.js +593 -0
  45. package/src/core/geom/3d/shape/TransformedShape3D.d.ts.map +1 -1
  46. package/src/core/geom/3d/shape/TransformedShape3D.js +46 -2
  47. package/src/core/geom/3d/shape/Triangle3D.d.ts +95 -0
  48. package/src/core/geom/3d/shape/Triangle3D.d.ts.map +1 -0
  49. package/src/core/geom/3d/shape/Triangle3D.js +318 -0
  50. package/src/core/geom/3d/shape/UnionShape3D.js +13 -0
  51. package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts +37 -9
  52. package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts.map +1 -1
  53. package/src/core/geom/3d/shape/UnitCubeShape3D.js +45 -98
  54. package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts +10 -0
  55. package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts.map +1 -1
  56. package/src/core/geom/3d/shape/UnitSphereShape3D.js +11 -0
  57. package/src/core/geom/3d/shape/shape_mesh_from_geometry.d.ts +30 -0
  58. package/src/core/geom/3d/shape/shape_mesh_from_geometry.d.ts.map +1 -0
  59. package/src/core/geom/3d/shape/shape_mesh_from_geometry.js +64 -0
  60. package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.d.ts +61 -0
  61. package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.d.ts.map +1 -0
  62. package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.js +148 -0
  63. package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.d.ts +39 -0
  64. package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.d.ts.map +1 -0
  65. package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.js +147 -0
  66. package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.d.ts +15 -0
  67. package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.d.ts.map +1 -0
  68. package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.js +22 -0
  69. package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.d.ts +2 -0
  70. package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.d.ts.map +1 -0
  71. package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.js +671 -0
  72. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_build_vertex_to_tets_map.d.ts +28 -0
  73. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_build_vertex_to_tets_map.d.ts.map +1 -0
  74. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_build_vertex_to_tets_map.js +48 -0
  75. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.d.ts +26 -0
  76. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.d.ts.map +1 -0
  77. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.js +222 -0
  78. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.d.ts +34 -0
  79. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.d.ts.map +1 -0
  80. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.js +146 -0
  81. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.d.ts +36 -0
  82. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.d.ts.map +1 -0
  83. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.js +232 -0
  84. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.d.ts +33 -0
  85. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.d.ts.map +1 -0
  86. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.js +255 -0
  87. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.d.ts +68 -0
  88. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.d.ts.map +1 -0
  89. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.js +387 -0
  90. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.d.ts +35 -0
  91. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.d.ts.map +1 -0
  92. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.js +140 -0
  93. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.d.ts +31 -0
  94. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.d.ts.map +1 -0
  95. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.js +97 -0
  96. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.d.ts +32 -0
  97. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.d.ts.map +1 -0
  98. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.js +66 -0
  99. package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts +41 -0
  100. package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts.map +1 -1
  101. package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.js +124 -13
  102. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.d.ts +134 -0
  103. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.d.ts.map +1 -1
  104. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.js +276 -3
  105. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts +17 -0
  106. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts.map +1 -0
  107. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.js +135 -0
  108. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.d.ts +14 -0
  109. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.d.ts.map +1 -0
  110. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.js +177 -0
  111. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.d.ts.map +1 -1
  112. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.js +20 -4
  113. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.d.ts.map +1 -1
  114. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.js +5 -3
  115. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_create.d.ts.map +1 -1
  116. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_create.js +9 -0
  117. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_get_or_create.d.ts.map +1 -1
  118. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_get_or_create.js +21 -45
  119. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill.d.ts.map +1 -1
  120. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill.js +7 -1
  121. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts +8 -6
  122. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts.map +1 -1
  123. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.js +8 -6
  124. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.d.ts +22 -0
  125. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.d.ts.map +1 -0
  126. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.js +73 -0
  127. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.d.ts.map +1 -1
  128. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.js +51 -1
  129. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.d.ts +10 -0
  130. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.d.ts.map +1 -0
  131. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.js +42 -0
  132. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.d.ts +28 -0
  133. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.d.ts.map +1 -0
  134. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.js +227 -0
  135. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.d.ts +13 -0
  136. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.d.ts.map +1 -0
  137. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.js +108 -0
  138. package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.d.ts +11 -0
  139. package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.d.ts.map +1 -0
  140. package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.js +20 -0
  141. package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.d.ts +20 -0
  142. package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.d.ts.map +1 -0
  143. package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.js +38 -0
  144. package/src/core/geom/3d/triangle/v3_compute_triangle_normal.d.ts +2 -2
  145. package/src/core/geom/3d/triangle/v3_compute_triangle_normal.d.ts.map +1 -1
  146. package/src/core/geom/3d/triangle/v3_compute_triangle_normal.js +1 -1
  147. package/src/core/geom/vec3/v3_dot_array_array.d.ts +3 -3
  148. package/src/core/geom/vec3/v3_dot_array_array.d.ts.map +1 -1
  149. package/src/core/geom/vec3/v3_dot_array_array.js +2 -2
  150. package/src/core/geom/vec3/v3_negate_array.d.ts +3 -3
  151. package/src/core/geom/vec3/v3_negate_array.d.ts.map +1 -1
  152. package/src/core/geom/vec3/v3_negate_array.js +2 -2
  153. package/src/core/geom/vec3/v3_quat3_apply.d.ts +29 -0
  154. package/src/core/geom/vec3/v3_quat3_apply.d.ts.map +1 -0
  155. package/src/core/geom/vec3/v3_quat3_apply.js +39 -0
  156. package/src/core/geom/vec3/v3_quat3_apply_inverse.d.ts +30 -0
  157. package/src/core/geom/vec3/v3_quat3_apply_inverse.d.ts.map +1 -0
  158. package/src/core/geom/vec3/v3_quat3_apply_inverse.js +41 -0
  159. package/src/core/geom/vec3/v3_triple_cross_product.d.ts +32 -0
  160. package/src/core/geom/vec3/v3_triple_cross_product.d.ts.map +1 -0
  161. package/src/core/geom/vec3/v3_triple_cross_product.js +45 -0
  162. package/src/core/graph/csr/CSRGraph.d.ts +168 -0
  163. package/src/core/graph/csr/CSRGraph.d.ts.map +1 -0
  164. package/src/core/graph/csr/CSRGraph.js +319 -0
  165. package/src/core/graph/metis/cluster_mesh_metis.d.ts +12 -0
  166. package/src/core/graph/metis/cluster_mesh_metis.d.ts.map +1 -1
  167. package/src/core/graph/metis/cluster_mesh_metis.js +12 -0
  168. package/src/core/graph/metis/metis.d.ts +19 -0
  169. package/src/core/graph/metis/metis.d.ts.map +1 -1
  170. package/src/core/graph/metis/metis.js +20 -0
  171. package/src/core/graph/metis/metis_cluster_bs.d.ts +11 -0
  172. package/src/core/graph/metis/metis_cluster_bs.d.ts.map +1 -1
  173. package/src/core/graph/metis/metis_cluster_bs.js +11 -0
  174. package/src/core/graph/metis/metis_options.d.ts +17 -2
  175. package/src/core/graph/metis/metis_options.d.ts.map +1 -1
  176. package/src/core/graph/metis/metis_options.js +17 -2
  177. package/src/core/graph/metis/native/MetisGraph.d.ts +144 -0
  178. package/src/core/graph/metis/native/MetisGraph.d.ts.map +1 -0
  179. package/src/core/graph/metis/native/MetisGraph.js +212 -0
  180. package/src/core/graph/metis/native/bisection/BisectionScratch.d.ts +72 -0
  181. package/src/core/graph/metis/native/bisection/BisectionScratch.d.ts.map +1 -0
  182. package/src/core/graph/metis/native/bisection/BisectionScratch.js +101 -0
  183. package/src/core/graph/metis/native/bisection/bisect_graph.d.ts +37 -0
  184. package/src/core/graph/metis/native/bisection/bisect_graph.d.ts.map +1 -0
  185. package/src/core/graph/metis/native/bisection/bisect_graph.js +100 -0
  186. package/src/core/graph/metis/native/bisection/compute_2way_params.d.ts +15 -0
  187. package/src/core/graph/metis/native/bisection/compute_2way_params.d.ts.map +1 -0
  188. package/src/core/graph/metis/native/bisection/compute_2way_params.js +84 -0
  189. package/src/core/graph/metis/native/bisection/fm_2way.d.ts +30 -0
  190. package/src/core/graph/metis/native/bisection/fm_2way.d.ts.map +1 -0
  191. package/src/core/graph/metis/native/bisection/fm_2way.js +290 -0
  192. package/src/core/graph/metis/native/bisection/grow_bisection.d.ts +23 -0
  193. package/src/core/graph/metis/native/bisection/grow_bisection.d.ts.map +1 -0
  194. package/src/core/graph/metis/native/bisection/grow_bisection.js +137 -0
  195. package/src/core/graph/metis/native/bisection/split_graph_two_way.d.ts +28 -0
  196. package/src/core/graph/metis/native/bisection/split_graph_two_way.d.ts.map +1 -0
  197. package/src/core/graph/metis/native/bisection/split_graph_two_way.js +119 -0
  198. package/src/core/graph/metis/native/coarsen/coarsen_graph.d.ts +20 -0
  199. package/src/core/graph/metis/native/coarsen/coarsen_graph.d.ts.map +1 -0
  200. package/src/core/graph/metis/native/coarsen/coarsen_graph.js +94 -0
  201. package/src/core/graph/metis/native/coarsen/create_coarse_graph.d.ts +24 -0
  202. package/src/core/graph/metis/native/coarsen/create_coarse_graph.d.ts.map +1 -0
  203. package/src/core/graph/metis/native/coarsen/create_coarse_graph.js +158 -0
  204. package/src/core/graph/metis/native/coarsen/match_shem.d.ts +41 -0
  205. package/src/core/graph/metis/native/coarsen/match_shem.d.ts.map +1 -0
  206. package/src/core/graph/metis/native/coarsen/match_shem.js +175 -0
  207. package/src/core/graph/metis/native/initial/initial_kway_bfs.d.ts +24 -0
  208. package/src/core/graph/metis/native/initial/initial_kway_bfs.d.ts.map +1 -0
  209. package/src/core/graph/metis/native/initial/initial_kway_bfs.js +122 -0
  210. package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.d.ts +29 -0
  211. package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.d.ts.map +1 -0
  212. package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.js +170 -0
  213. package/src/core/graph/metis/native/metis_partition_kway.d.ts +41 -0
  214. package/src/core/graph/metis/native/metis_partition_kway.d.ts.map +1 -0
  215. package/src/core/graph/metis/native/metis_partition_kway.js +126 -0
  216. package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.d.ts +62 -0
  217. package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.d.ts.map +1 -0
  218. package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.js +261 -0
  219. package/src/core/graph/metis/native/refine/RefinementScratch.d.ts +45 -0
  220. package/src/core/graph/metis/native/refine/RefinementScratch.d.ts.map +1 -0
  221. package/src/core/graph/metis/native/refine/RefinementScratch.js +53 -0
  222. package/src/core/graph/metis/native/refine/compute_kway_params.d.ts +18 -0
  223. package/src/core/graph/metis/native/refine/compute_kway_params.d.ts.map +1 -0
  224. package/src/core/graph/metis/native/refine/compute_kway_params.js +138 -0
  225. package/src/core/graph/metis/native/refine/fm_kway.d.ts +63 -0
  226. package/src/core/graph/metis/native/refine/fm_kway.d.ts.map +1 -0
  227. package/src/core/graph/metis/native/refine/fm_kway.js +462 -0
  228. package/src/core/graph/metis/native/refine/project_kway.d.ts +22 -0
  229. package/src/core/graph/metis/native/refine/project_kway.d.ts.map +1 -0
  230. package/src/core/graph/metis/native/refine/project_kway.js +43 -0
  231. package/src/core/graph/metis/native/refine/refine_kway.d.ts +34 -0
  232. package/src/core/graph/metis/native/refine/refine_kway.d.ts.map +1 -0
  233. package/src/core/graph/metis/native/refine/refine_kway.js +43 -0
  234. package/src/core/math/linalg/eigen/matrix_householder_in_place.d.ts +2 -2
  235. package/src/core/math/linalg/eigen/matrix_householder_in_place.js +2 -2
  236. package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts +6 -4
  237. package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts.map +1 -1
  238. package/src/core/math/linalg/eigen/matrix_qr_in_place.js +69 -23
  239. package/src/engine/EngineHarness.d.ts +3 -1
  240. package/src/engine/EngineHarness.d.ts.map +1 -1
  241. package/src/engine/EngineHarness.js +3 -0
  242. package/src/engine/control/first-person/DESIGN.md +30 -6
  243. package/src/engine/control/first-person/DESIGN_EXTENSIONS.md +563 -0
  244. package/src/engine/control/first-person/FirstPersonPlayerController.d.ts +115 -9
  245. package/src/engine/control/first-person/FirstPersonPlayerController.d.ts.map +1 -1
  246. package/src/engine/control/first-person/FirstPersonPlayerController.js +211 -176
  247. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts +601 -8
  248. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts.map +1 -1
  249. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.js +349 -8
  250. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts +319 -23
  251. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -1
  252. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +1789 -799
  253. package/src/engine/control/first-person/TODO.md +173 -0
  254. package/src/engine/control/first-person/abilities/Ability.d.ts +101 -0
  255. package/src/engine/control/first-person/abilities/Ability.d.ts.map +1 -0
  256. package/src/engine/control/first-person/abilities/Ability.js +119 -0
  257. package/src/engine/control/first-person/abilities/AbilitySet.d.ts +86 -0
  258. package/src/engine/control/first-person/abilities/AbilitySet.d.ts.map +1 -0
  259. package/src/engine/control/first-person/abilities/AbilitySet.js +185 -0
  260. package/src/engine/control/first-person/abilities/LedgeGrab.d.ts +62 -0
  261. package/src/engine/control/first-person/abilities/LedgeGrab.d.ts.map +1 -0
  262. package/src/engine/control/first-person/abilities/LedgeGrab.js +199 -0
  263. package/src/engine/control/first-person/abilities/Mantle.d.ts +45 -0
  264. package/src/engine/control/first-person/abilities/Mantle.d.ts.map +1 -0
  265. package/src/engine/control/first-person/abilities/Mantle.js +188 -0
  266. package/src/engine/control/first-person/abilities/Slide.d.ts +33 -0
  267. package/src/engine/control/first-person/abilities/Slide.d.ts.map +1 -0
  268. package/src/engine/control/first-person/abilities/Slide.js +166 -0
  269. package/src/engine/control/first-person/abilities/WallJump.d.ts +45 -0
  270. package/src/engine/control/first-person/abilities/WallJump.d.ts.map +1 -0
  271. package/src/engine/control/first-person/abilities/WallJump.js +131 -0
  272. package/src/engine/control/first-person/abilities/WallRun.d.ts +44 -0
  273. package/src/engine/control/first-person/abilities/WallRun.d.ts.map +1 -0
  274. package/src/engine/control/first-person/abilities/WallRun.js +180 -0
  275. package/src/engine/control/first-person/composer/EyeOffsetStack.d.ts +49 -0
  276. package/src/engine/control/first-person/composer/EyeOffsetStack.d.ts.map +1 -0
  277. package/src/engine/control/first-person/composer/EyeOffsetStack.js +60 -0
  278. package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.d.ts +100 -0
  279. package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.d.ts.map +1 -0
  280. package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.js +133 -0
  281. package/src/engine/control/first-person/mastery/DecisionPoint.d.ts +10 -0
  282. package/src/engine/control/first-person/mastery/DecisionPoint.d.ts.map +1 -0
  283. package/src/engine/control/first-person/mastery/DecisionPoint.js +30 -0
  284. package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.d.ts +61 -0
  285. package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.d.ts.map +1 -0
  286. package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.js +109 -0
  287. package/src/engine/control/first-person/mastery/MasteryEvaluator.d.ts +40 -0
  288. package/src/engine/control/first-person/mastery/MasteryEvaluator.d.ts.map +1 -0
  289. package/src/engine/control/first-person/mastery/MasteryEvaluator.js +45 -0
  290. package/src/engine/control/first-person/mastery/MasteryScore.d.ts +68 -0
  291. package/src/engine/control/first-person/mastery/MasteryScore.d.ts.map +1 -0
  292. package/src/engine/control/first-person/mastery/MasteryScore.js +100 -0
  293. package/src/engine/control/first-person/mastery/MasterySet.d.ts +60 -0
  294. package/src/engine/control/first-person/mastery/MasterySet.d.ts.map +1 -0
  295. package/src/engine/control/first-person/mastery/MasterySet.js +86 -0
  296. package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.d.ts +58 -0
  297. package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.d.ts.map +1 -0
  298. package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.js +83 -0
  299. package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.d.ts +69 -0
  300. package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.d.ts.map +1 -0
  301. package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.js +109 -0
  302. package/src/engine/control/first-person/math/Spring.d.ts +56 -0
  303. package/src/engine/control/first-person/math/Spring.d.ts.map +1 -0
  304. package/src/engine/control/first-person/math/Spring.js +71 -0
  305. package/src/engine/control/first-person/math/computeLRCBreathRate.d.ts +26 -0
  306. package/src/engine/control/first-person/math/computeLRCBreathRate.d.ts.map +1 -0
  307. package/src/engine/control/first-person/math/computeLRCBreathRate.js +41 -0
  308. package/src/engine/control/first-person/math/computeMassRatios.d.ts +35 -0
  309. package/src/engine/control/first-person/math/computeMassRatios.d.ts.map +1 -0
  310. package/src/engine/control/first-person/math/computeMassRatios.js +44 -0
  311. package/src/engine/control/first-person/pose/FirstPersonPose.d.ts +31 -1
  312. package/src/engine/control/first-person/pose/FirstPersonPose.d.ts.map +1 -1
  313. package/src/engine/control/first-person/pose/FirstPersonPose.js +49 -3
  314. package/src/engine/control/first-person/pose/FirstPersonPosture.d.ts +7 -0
  315. package/src/engine/control/first-person/pose/FirstPersonPosture.d.ts.map +1 -0
  316. package/src/engine/control/first-person/pose/FirstPersonPosture.js +27 -0
  317. package/src/engine/control/first-person/prototype_first_person_controller.js +637 -120
  318. package/src/engine/control/first-person/sensors/FirstPersonSensors.d.ts +58 -0
  319. package/src/engine/control/first-person/sensors/FirstPersonSensors.d.ts.map +1 -0
  320. package/src/engine/control/first-person/sensors/FirstPersonSensors.js +77 -0
  321. package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts +80 -0
  322. package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts.map +1 -0
  323. package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.js +196 -0
  324. package/src/engine/control/first-person/test/buildTestPlayer.d.ts +20 -0
  325. package/src/engine/control/first-person/test/buildTestPlayer.d.ts.map +1 -0
  326. package/src/engine/control/first-person/test/buildTestPlayer.js +36 -0
  327. package/src/engine/graphics/camera/testClippingPlaneComputation.js +0 -2
  328. package/src/engine/graphics/ecs/light/Light.d.ts.map +1 -1
  329. package/src/engine/graphics/ecs/light/Light.js +27 -0
  330. package/src/engine/graphics/ecs/light/LightSystem.js +1 -1
  331. package/src/engine/graphics/ecs/path/PathDisplaySystem.d.ts.map +1 -1
  332. package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
  333. package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +0 -2
  334. package/src/engine/graphics/geometry/CapsuleGeometry.d.ts +42 -0
  335. package/src/engine/graphics/geometry/CapsuleGeometry.d.ts.map +1 -0
  336. package/src/engine/graphics/geometry/CapsuleGeometry.js +171 -0
  337. package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -2
  338. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +0 -2
  339. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +0 -2
  340. package/src/engine/navigation/grid/find_path_on_grid_astar.d.ts.map +1 -1
  341. package/src/engine/navigation/grid/find_path_on_grid_astar.js +11 -2
  342. package/src/engine/navigation/mesh/bt_mesh_face_find_path.d.ts.map +1 -1
  343. package/src/engine/navigation/mesh/bt_mesh_face_find_path.js +11 -1
  344. package/src/engine/physics/BULLET_REVIEW.md +945 -0
  345. package/src/engine/physics/CANNON_REVIEW.md +1300 -0
  346. package/src/engine/physics/JOLT_REVIEW.md +913 -0
  347. package/src/engine/physics/PLAN.md +461 -0
  348. package/src/engine/physics/RAPIER_REVIEW.md +934 -0
  349. package/src/engine/physics/REVIEW_001_ACTION_PLAN.md +642 -0
  350. package/src/engine/physics/body/BodyStorage.d.ts +187 -0
  351. package/src/engine/physics/body/BodyStorage.d.ts.map +1 -0
  352. package/src/engine/physics/body/BodyStorage.js +427 -0
  353. package/src/engine/physics/broadphase/PairList.d.ts +62 -0
  354. package/src/engine/physics/broadphase/PairList.d.ts.map +1 -0
  355. package/src/engine/physics/broadphase/PairList.js +97 -0
  356. package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts +16 -0
  357. package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts.map +1 -0
  358. package/src/engine/physics/broadphase/compute_fat_world_aabb.js +61 -0
  359. package/src/engine/physics/broadphase/generate_pairs.d.ts +38 -0
  360. package/src/engine/physics/broadphase/generate_pairs.d.ts.map +1 -0
  361. package/src/engine/physics/broadphase/generate_pairs.js +101 -0
  362. package/src/engine/physics/contact/ManifoldStore.d.ts +299 -0
  363. package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -0
  364. package/src/engine/physics/contact/ManifoldStore.js +608 -0
  365. package/src/engine/physics/ecs/BodyKind.d.ts +23 -0
  366. package/src/engine/physics/ecs/BodyKind.d.ts.map +1 -0
  367. package/src/engine/physics/ecs/BodyKind.js +24 -0
  368. package/src/engine/physics/ecs/Collider.d.ts +98 -0
  369. package/src/engine/physics/ecs/Collider.d.ts.map +1 -0
  370. package/src/engine/physics/ecs/Collider.js +136 -0
  371. package/src/engine/physics/ecs/ColliderFlags.d.ts +14 -0
  372. package/src/engine/physics/ecs/ColliderFlags.d.ts.map +1 -0
  373. package/src/engine/physics/ecs/ColliderFlags.js +15 -0
  374. package/src/engine/physics/ecs/ColliderObserverSystem.d.ts +58 -0
  375. package/src/engine/physics/ecs/ColliderObserverSystem.d.ts.map +1 -0
  376. package/src/engine/physics/ecs/ColliderObserverSystem.js +103 -0
  377. package/src/engine/physics/ecs/ColliderSerializationAdapter.d.ts +25 -0
  378. package/src/engine/physics/ecs/ColliderSerializationAdapter.d.ts.map +1 -0
  379. package/src/engine/physics/ecs/ColliderSerializationAdapter.js +37 -0
  380. package/src/engine/physics/ecs/PhysicsEvents.d.ts +15 -0
  381. package/src/engine/physics/ecs/PhysicsEvents.d.ts.map +1 -0
  382. package/src/engine/physics/ecs/PhysicsEvents.js +16 -0
  383. package/src/engine/physics/ecs/PhysicsSystem.d.ts +628 -0
  384. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -0
  385. package/src/engine/physics/ecs/PhysicsSystem.js +1301 -0
  386. package/src/engine/physics/ecs/RigidBody.d.ts +197 -0
  387. package/src/engine/physics/ecs/RigidBody.d.ts.map +1 -0
  388. package/src/engine/physics/ecs/RigidBody.js +240 -0
  389. package/src/engine/physics/ecs/RigidBodyFlags.d.ts +21 -0
  390. package/src/engine/physics/ecs/RigidBodyFlags.d.ts.map +1 -0
  391. package/src/engine/physics/ecs/RigidBodyFlags.js +22 -0
  392. package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts +28 -0
  393. package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts.map +1 -0
  394. package/src/engine/physics/ecs/RigidBodySerializationAdapter.js +81 -0
  395. package/src/engine/physics/ecs/SleepState.d.ts +11 -0
  396. package/src/engine/physics/ecs/SleepState.d.ts.map +1 -0
  397. package/src/engine/physics/ecs/SleepState.js +12 -0
  398. package/src/engine/physics/events/ContactEventBuffer.d.ts +46 -0
  399. package/src/engine/physics/events/ContactEventBuffer.d.ts.map +1 -0
  400. package/src/engine/physics/events/ContactEventBuffer.js +83 -0
  401. package/src/engine/physics/events/diff_manifolds.d.ts +25 -0
  402. package/src/engine/physics/events/diff_manifolds.d.ts.map +1 -0
  403. package/src/engine/physics/events/diff_manifolds.js +50 -0
  404. package/src/engine/physics/fluid/FluidField.d.ts +294 -16
  405. package/src/engine/physics/fluid/FluidField.d.ts.map +1 -1
  406. package/src/engine/physics/fluid/FluidField.js +510 -66
  407. package/src/engine/physics/fluid/FluidSimulator.d.ts +188 -5
  408. package/src/engine/physics/fluid/FluidSimulator.d.ts.map +1 -1
  409. package/src/engine/physics/fluid/FluidSimulator.js +456 -95
  410. package/src/engine/physics/fluid/SliceVisualiser.d.ts +29 -6
  411. package/src/engine/physics/fluid/SliceVisualiser.d.ts.map +1 -1
  412. package/src/engine/physics/fluid/SliceVisualiser.js +190 -165
  413. package/src/engine/physics/fluid/ecs/FluidComponent.d.ts +154 -0
  414. package/src/engine/physics/fluid/ecs/FluidComponent.d.ts.map +1 -0
  415. package/src/engine/physics/fluid/ecs/FluidComponent.js +238 -0
  416. package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.d.ts +45 -0
  417. package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.d.ts.map +1 -0
  418. package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.js +89 -0
  419. package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +107 -0
  420. package/src/engine/physics/fluid/ecs/FluidSystem.d.ts.map +1 -0
  421. package/src/engine/physics/fluid/ecs/FluidSystem.js +278 -0
  422. package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts +62 -1
  423. package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts.map +1 -1
  424. package/src/engine/physics/fluid/effector/AbstractFluidEffector.js +81 -6
  425. package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts +17 -4
  426. package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts.map +1 -1
  427. package/src/engine/physics/fluid/effector/GlobalFluidEffector.js +105 -12
  428. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts +43 -0
  429. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts.map +1 -0
  430. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.js +210 -0
  431. package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts +62 -1
  432. package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts.map +1 -1
  433. package/src/engine/physics/fluid/effector/WakeFluidEffector.js +302 -8
  434. package/src/engine/physics/fluid/prototype.js +102 -91
  435. package/src/engine/physics/fluid/solver/optimal_sor_omega.d.ts +33 -0
  436. package/src/engine/physics/fluid/solver/optimal_sor_omega.d.ts.map +1 -0
  437. package/src/engine/physics/fluid/solver/optimal_sor_omega.js +41 -0
  438. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.d.ts +20 -5
  439. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.d.ts.map +1 -1
  440. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.js +60 -38
  441. package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.d.ts +25 -4
  442. package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.d.ts.map +1 -1
  443. package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.js +93 -73
  444. package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.d.ts +23 -0
  445. package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.d.ts.map +1 -0
  446. package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.js +60 -0
  447. package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.d.ts +23 -0
  448. package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.d.ts.map +1 -0
  449. package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.js +68 -0
  450. package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts +30 -0
  451. package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts.map +1 -0
  452. package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.js +66 -0
  453. package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.d.ts +26 -0
  454. package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.d.ts.map +1 -0
  455. package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.js +113 -0
  456. package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.d.ts +30 -0
  457. package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.d.ts.map +1 -0
  458. package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.js +107 -0
  459. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts +49 -0
  460. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts.map +1 -0
  461. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.js +126 -0
  462. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts +93 -0
  463. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts.map +1 -0
  464. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.js +424 -0
  465. package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts +48 -0
  466. package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts.map +1 -0
  467. package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.js +92 -0
  468. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts +6 -6
  469. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts.map +1 -1
  470. package/src/engine/physics/gjk/expanding_polytope_algorithm.js +76 -32
  471. package/src/engine/physics/gjk/gjk.d.ts +28 -2
  472. package/src/engine/physics/gjk/gjk.d.ts.map +1 -1
  473. package/src/engine/physics/gjk/gjk.js +421 -378
  474. package/src/engine/physics/gjk/minkowski_support.d.ts +37 -0
  475. package/src/engine/physics/gjk/minkowski_support.d.ts.map +1 -0
  476. package/src/engine/physics/gjk/minkowski_support.js +75 -0
  477. package/src/engine/physics/gjk/mpr.d.ts +56 -0
  478. package/src/engine/physics/gjk/mpr.d.ts.map +1 -0
  479. package/src/engine/physics/gjk/mpr.js +344 -0
  480. package/src/engine/physics/inertia/world_inverse_inertia.d.ts +44 -0
  481. package/src/engine/physics/inertia/world_inverse_inertia.d.ts.map +1 -0
  482. package/src/engine/physics/inertia/world_inverse_inertia.js +77 -0
  483. package/src/engine/physics/integration/integrate_position.d.ts +34 -0
  484. package/src/engine/physics/integration/integrate_position.d.ts.map +1 -0
  485. package/src/engine/physics/integration/integrate_position.js +79 -0
  486. package/src/engine/physics/integration/integrate_velocity.d.ts +55 -0
  487. package/src/engine/physics/integration/integrate_velocity.d.ts.map +1 -0
  488. package/src/engine/physics/integration/integrate_velocity.js +160 -0
  489. package/src/engine/physics/integration/quat_integrate.d.ts +27 -0
  490. package/src/engine/physics/integration/quat_integrate.d.ts.map +1 -0
  491. package/src/engine/physics/integration/quat_integrate.js +62 -0
  492. package/src/engine/physics/island/IslandBuilder.d.ts +167 -0
  493. package/src/engine/physics/island/IslandBuilder.d.ts.map +1 -0
  494. package/src/engine/physics/island/IslandBuilder.js +411 -0
  495. package/src/engine/physics/island/union_find.d.ts +51 -0
  496. package/src/engine/physics/island/union_find.d.ts.map +1 -0
  497. package/src/engine/physics/island/union_find.js +76 -0
  498. package/src/engine/physics/narrowphase/PosedShape.d.ts +51 -0
  499. package/src/engine/physics/narrowphase/PosedShape.d.ts.map +1 -0
  500. package/src/engine/physics/narrowphase/PosedShape.js +108 -0
  501. package/src/engine/physics/narrowphase/box_box_manifold.d.ts +32 -0
  502. package/src/engine/physics/narrowphase/box_box_manifold.d.ts.map +1 -0
  503. package/src/engine/physics/narrowphase/box_box_manifold.js +639 -0
  504. package/src/engine/physics/narrowphase/box_triangle_contact.d.ts +30 -0
  505. package/src/engine/physics/narrowphase/box_triangle_contact.d.ts.map +1 -0
  506. package/src/engine/physics/narrowphase/box_triangle_contact.js +811 -0
  507. package/src/engine/physics/narrowphase/capsule_contacts.d.ts +122 -0
  508. package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -0
  509. package/src/engine/physics/narrowphase/capsule_contacts.js +462 -0
  510. package/src/engine/physics/narrowphase/capsule_triangle_contact.d.ts +71 -0
  511. package/src/engine/physics/narrowphase/capsule_triangle_contact.d.ts.map +1 -0
  512. package/src/engine/physics/narrowphase/capsule_triangle_contact.js +375 -0
  513. package/src/engine/physics/narrowphase/compute_penetration.d.ts +91 -0
  514. package/src/engine/physics/narrowphase/compute_penetration.d.ts.map +1 -0
  515. package/src/engine/physics/narrowphase/compute_penetration.js +396 -0
  516. package/src/engine/physics/narrowphase/decomposition/aabb_world_to_local.d.ts +35 -0
  517. package/src/engine/physics/narrowphase/decomposition/aabb_world_to_local.d.ts.map +1 -0
  518. package/src/engine/physics/narrowphase/decomposition/aabb_world_to_local.js +80 -0
  519. package/src/engine/physics/narrowphase/decomposition/decompose_to_triangles.d.ts +31 -0
  520. package/src/engine/physics/narrowphase/decomposition/decompose_to_triangles.d.ts.map +1 -0
  521. package/src/engine/physics/narrowphase/decomposition/decompose_to_triangles.js +55 -0
  522. package/src/engine/physics/narrowphase/decomposition/heightmap_enumerate_triangles.d.ts +42 -0
  523. package/src/engine/physics/narrowphase/decomposition/heightmap_enumerate_triangles.d.ts.map +1 -0
  524. package/src/engine/physics/narrowphase/decomposition/heightmap_enumerate_triangles.js +204 -0
  525. package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.d.ts +42 -0
  526. package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.d.ts.map +1 -0
  527. package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.js +94 -0
  528. package/src/engine/physics/narrowphase/decomposition/triangle_buffer_layout.d.ts +37 -0
  529. package/src/engine/physics/narrowphase/decomposition/triangle_buffer_layout.d.ts.map +1 -0
  530. package/src/engine/physics/narrowphase/decomposition/triangle_buffer_layout.js +37 -0
  531. package/src/engine/physics/narrowphase/narrowphase_step.d.ts +17 -0
  532. package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -0
  533. package/src/engine/physics/narrowphase/narrowphase_step.js +1422 -0
  534. package/src/engine/physics/narrowphase/sphere_box_contact.d.ts +38 -0
  535. package/src/engine/physics/narrowphase/sphere_box_contact.d.ts.map +1 -0
  536. package/src/engine/physics/narrowphase/sphere_box_contact.js +123 -0
  537. package/src/engine/physics/narrowphase/sphere_sphere_contact.d.ts +26 -0
  538. package/src/engine/physics/narrowphase/sphere_sphere_contact.d.ts.map +1 -0
  539. package/src/engine/physics/narrowphase/sphere_sphere_contact.js +51 -0
  540. package/src/engine/physics/narrowphase/sphere_triangle_contact.d.ts +48 -0
  541. package/src/engine/physics/narrowphase/sphere_triangle_contact.d.ts.map +1 -0
  542. package/src/engine/physics/narrowphase/sphere_triangle_contact.js +143 -0
  543. package/src/engine/physics/queries/PhysicsSurfacePoint.d.ts +83 -0
  544. package/src/engine/physics/queries/PhysicsSurfacePoint.d.ts.map +1 -0
  545. package/src/engine/physics/queries/PhysicsSurfacePoint.js +100 -0
  546. package/src/engine/physics/queries/overlap_shape.d.ts +51 -0
  547. package/src/engine/physics/queries/overlap_shape.d.ts.map +1 -0
  548. package/src/engine/physics/queries/overlap_shape.js +183 -0
  549. package/src/engine/physics/queries/raycast.d.ts +20 -0
  550. package/src/engine/physics/queries/raycast.d.ts.map +1 -0
  551. package/src/engine/physics/queries/raycast.js +249 -0
  552. package/src/engine/physics/queries/shape_cast.d.ts +56 -0
  553. package/src/engine/physics/queries/shape_cast.d.ts.map +1 -0
  554. package/src/engine/physics/queries/shape_cast.js +387 -0
  555. package/src/engine/physics/solver/friction_cone.d.ts +16 -0
  556. package/src/engine/physics/solver/friction_cone.d.ts.map +1 -0
  557. package/src/engine/physics/solver/friction_cone.js +37 -0
  558. package/src/engine/physics/solver/solve_contacts.d.ts +122 -0
  559. package/src/engine/physics/solver/solve_contacts.d.ts.map +1 -0
  560. package/src/engine/physics/solver/solve_contacts.js +1016 -0
  561. package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.d.ts +0 -34
  562. package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.d.ts.map +0 -1
  563. package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.js +0 -66
  564. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.d.ts +0 -2
  565. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.d.ts.map +0 -1
  566. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.js +0 -54
  567. package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.d.ts +0 -2
  568. package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.d.ts.map +0 -1
  569. package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.js +0 -26
  570. package/src/engine/ecs/components/Motion.d.ts +0 -21
  571. package/src/engine/ecs/components/Motion.d.ts.map +0 -1
  572. package/src/engine/ecs/components/Motion.js +0 -27
  573. package/src/engine/ecs/components/MotionSerializationAdapter.d.ts +0 -20
  574. package/src/engine/ecs/components/MotionSerializationAdapter.d.ts.map +0 -1
  575. package/src/engine/ecs/components/MotionSerializationAdapter.js +0 -26
  576. package/src/engine/ecs/systems/MotionSystem.d.ts +0 -9
  577. package/src/engine/ecs/systems/MotionSystem.d.ts.map +0 -1
  578. package/src/engine/ecs/systems/MotionSystem.js +0 -29
  579. package/src/engine/physics/fluid/Fluid.d.ts +0 -26
  580. package/src/engine/physics/fluid/Fluid.d.ts.map +0 -1
  581. package/src/engine/physics/fluid/Fluid.js +0 -221
  582. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.d.ts +0 -7
  583. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.d.ts.map +0 -1
  584. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.js +0 -8
@@ -0,0 +1,639 @@
1
+ import { line3_closest_points_segment_segment } from "../../../core/geom/3d/line/line3_closest_points_segment_segment.js";
2
+ import { quat3_to_matrix3 } from "../../../core/geom/3d/quaternion/quat3_to_matrix3.js";
3
+
4
+ /**
5
+ * Multi-point manifold construction for two oriented bounding boxes.
6
+ *
7
+ * Algorithm:
8
+ * 1. SAT over the canonical 15 axes (3 face normals of A, 3 of B, 9 edge-pair
9
+ * crosses) to find the smallest-overlap axis and remember whether it came
10
+ * from a face normal of A, a face normal of B, or an edge-pair cross.
11
+ * 2. Face axis ⇒ identify a reference face (on the box that owned the axis)
12
+ * and an incident face (on the opposite box, the face whose outward
13
+ * normal is most antiparallel to the contact normal). Project the four
14
+ * incident corners into the reference face's 2-D coordinate frame and
15
+ * clip the resulting quad against the reference face rectangle via
16
+ * Sutherland-Hodgman. Each surviving vertex with positive penetration
17
+ * becomes a contact point.
18
+ * 3. Edge-cross axis ⇒ a single contact at the body-centre midpoint
19
+ * (v1 fallback; closest-edge-points refinement is a follow-up).
20
+ * 4. If more than {@link MAX_CONTACTS} survive, reduce by picking the
21
+ * deepest first, then three more that maximise the perimeter of the
22
+ * resulting quad.
23
+ *
24
+ * Contact convention (matches the manifold cache): the normal points from
25
+ * box B toward box A; positive depth means penetration.
26
+ *
27
+ * Output layout:
28
+ * out[0..2] : world normal
29
+ * out[3] : contact count (0 .. {@link MAX_CONTACTS})
30
+ * out[4 + k*7 + 0..2] : world contact on A's surface
31
+ * out[4 + k*7 + 3..5] : world contact on B's surface
32
+ * out[4 + k*7 + 6] : penetration depth (positive)
33
+ *
34
+ * @author Alex Goldring
35
+ * @copyright Company Named Limited (c) 2026
36
+ */
37
+
38
+ const MAX_CONTACTS = 4;
39
+ const CONTACT_STRIDE = 7;
40
+ const PARALLEL_EPS_SQR = 1e-8;
41
+
42
+ /**
43
+ * Length of `out` required by {@link box_box_manifold}.
44
+ * @type {number}
45
+ */
46
+ export const BOX_BOX_OUT_LENGTH = 4 + MAX_CONTACTS * CONTACT_STRIDE;
47
+
48
+ // --- shared scratch storage -------------------------------------------------
49
+
50
+ const scratch_axes_a = new Float64Array(9);
51
+ const scratch_axes_b = new Float64Array(9);
52
+
53
+ // 4 incident face corners in world space.
54
+ const incident_world = new Float64Array(12);
55
+ // Clipped polygon — worst case 8 vertices (quad clipped by 4 planes).
56
+ const clip_in = new Float64Array(8 * 3);
57
+ const clip_out = new Float64Array(8 * 3);
58
+ // 2-D projection of incident corners onto reference-face uv plane.
59
+ const incident_uv = new Float64Array(8 * 2);
60
+ const clipped_uv_in = new Float64Array(8 * 2);
61
+ const clipped_uv_out = new Float64Array(8 * 2);
62
+
63
+ // Surviving 3-D contact points along with their (signed) depth.
64
+ // Stride 4 per candidate: x, y, z, depth.
65
+ const candidates = new Float64Array(8 * 4);
66
+
67
+ // Output of line3_closest_points_segment_segment for the edge-cross
68
+ // SAT-winner path: (s, t) parameters along the two edges.
69
+ const scratch_edge_st = new Float64Array(2);
70
+
71
+ // --- helpers ---------------------------------------------------------------
72
+
73
+ function projected_half_extent(axes, off, hx, hy, hz, lx, ly, lz) {
74
+ const px = lx * axes[off] + ly * axes[off + 1] + lz * axes[off + 2];
75
+ const py = lx * axes[off + 3] + ly * axes[off + 4] + lz * axes[off + 5];
76
+ const pz = lx * axes[off + 6] + ly * axes[off + 7] + lz * axes[off + 8];
77
+ return (px < 0 ? -px : px) * hx
78
+ + (py < 0 ? -py : py) * hy
79
+ + (pz < 0 ? -pz : pz) * hz;
80
+ }
81
+
82
+ /**
83
+ * Sutherland-Hodgman clip of `points_in_uv` (point_count vertices, stride 2)
84
+ * against the half-plane `coord_idx ≤ bound` (or `coord_idx ≥ bound` when
85
+ * `keep_below` is false). Result is written to `points_out_uv`, returns the
86
+ * vertex count.
87
+ *
88
+ * @param {Float64Array} points_in
89
+ * @param {number} point_count
90
+ * @param {Float64Array} points_out
91
+ * @param {number} coord_idx 0 = u, 1 = v
92
+ * @param {number} bound
93
+ * @param {boolean} keep_below true to keep points with coord ≤ bound
94
+ * @returns {number} surviving vertex count
95
+ */
96
+ function clip_against_axis(points_in, point_count, points_out, coord_idx, bound, keep_below) {
97
+ let out_count = 0;
98
+ for (let i = 0; i < point_count; i++) {
99
+ const j = (i + 1) % point_count;
100
+ const ax = points_in[i * 2], ay = points_in[i * 2 + 1];
101
+ const bx = points_in[j * 2], by = points_in[j * 2 + 1];
102
+ const av = coord_idx === 0 ? ax : ay;
103
+ const bv = coord_idx === 0 ? bx : by;
104
+ const a_inside = keep_below ? (av <= bound) : (av >= bound);
105
+ const b_inside = keep_below ? (bv <= bound) : (bv >= bound);
106
+
107
+ if (a_inside) {
108
+ // emit a
109
+ points_out[out_count * 2] = ax;
110
+ points_out[out_count * 2 + 1] = ay;
111
+ out_count++;
112
+ }
113
+ if (a_inside !== b_inside) {
114
+ // emit intersection on the bounding line
115
+ // Parameterise: p(t) = a + t * (b - a); solve coord(p(t)) = bound.
116
+ const denom = bv - av;
117
+ const t = denom !== 0 ? (bound - av) / denom : 0;
118
+ points_out[out_count * 2] = ax + (bx - ax) * t;
119
+ points_out[out_count * 2 + 1] = ay + (by - ay) * t;
120
+ out_count++;
121
+ }
122
+ }
123
+ return out_count;
124
+ }
125
+
126
+ // --- main -------------------------------------------------------------------
127
+
128
+ /**
129
+ *
130
+ * @param {number[]|Float64Array} out length >= BOX_BOX_OUT_LENGTH
131
+ * @param {number} ax centre x of A
132
+ * @param {number} ay
133
+ * @param {number} az
134
+ * @param {number} aqx A rotation quaternion x
135
+ * @param {number} aqy
136
+ * @param {number} aqz
137
+ * @param {number} aqw
138
+ * @param {number} ahx A half-extent x in body frame
139
+ * @param {number} ahy
140
+ * @param {number} ahz
141
+ * @param {number} bx centre x of B
142
+ * @param {number} by
143
+ * @param {number} bz
144
+ * @param {number} bqx
145
+ * @param {number} bqy
146
+ * @param {number} bqz
147
+ * @param {number} bqw
148
+ * @param {number} bhx
149
+ * @param {number} bhy
150
+ * @param {number} bhz
151
+ * @returns {boolean} true if overlap
152
+ */
153
+ export function box_box_manifold(
154
+ out,
155
+ ax, ay, az, aqx, aqy, aqz, aqw, ahx, ahy, ahz,
156
+ bx, by, bz, bqx, bqy, bqz, bqw, bhx, bhy, bhz
157
+ ) {
158
+ quat3_to_matrix3(scratch_axes_a, 0, aqx, aqy, aqz, aqw);
159
+ quat3_to_matrix3(scratch_axes_b, 0, bqx, bqy, bqz, bqw);
160
+
161
+ const ta = scratch_axes_a;
162
+ const tb = scratch_axes_b;
163
+
164
+ const dx = bx - ax;
165
+ const dy = by - ay;
166
+ const dz = bz - az;
167
+
168
+ // SAT — track winning axis + source.
169
+ // source: 0..2 = A face normal, 3..5 = B face normal, 6..14 = edge cross.
170
+ let best_overlap = Infinity;
171
+ let best_nx = 0, best_ny = 0, best_nz = 0;
172
+ let best_source = -1;
173
+
174
+ function test_axis(lx, ly, lz, source) {
175
+ const len_sqr = lx * lx + ly * ly + lz * lz;
176
+ if (len_sqr < PARALLEL_EPS_SQR) return false;
177
+ const inv_len = 1 / Math.sqrt(len_sqr);
178
+ const ux = lx * inv_len, uy = ly * inv_len, uz = lz * inv_len;
179
+ const rA = projected_half_extent(ta, 0, ahx, ahy, ahz, ux, uy, uz);
180
+ const rB = projected_half_extent(tb, 0, bhx, bhy, bhz, ux, uy, uz);
181
+ const proj = dx * ux + dy * uy + dz * uz;
182
+ const dist = proj < 0 ? -proj : proj;
183
+ const overlap = (rA + rB) - dist;
184
+ if (overlap < 0) return true;
185
+ if (overlap < best_overlap) {
186
+ best_overlap = overlap;
187
+ const sign = proj > 0 ? -1 : 1; // normal points B→A
188
+ best_nx = ux * sign;
189
+ best_ny = uy * sign;
190
+ best_nz = uz * sign;
191
+ best_source = source;
192
+ }
193
+ return false;
194
+ }
195
+
196
+ if (test_axis(ta[0], ta[1], ta[2], 0)) return false;
197
+ if (test_axis(ta[3], ta[4], ta[5], 1)) return false;
198
+ if (test_axis(ta[6], ta[7], ta[8], 2)) return false;
199
+ if (test_axis(tb[0], tb[1], tb[2], 3)) return false;
200
+ if (test_axis(tb[3], tb[4], tb[5], 4)) return false;
201
+ if (test_axis(tb[6], tb[7], tb[8], 5)) return false;
202
+
203
+ for (let i = 0; i < 3; i++) {
204
+ const aix = ta[i * 3], aiy = ta[i * 3 + 1], aiz = ta[i * 3 + 2];
205
+ for (let j = 0; j < 3; j++) {
206
+ const bjx = tb[j * 3], bjy = tb[j * 3 + 1], bjz = tb[j * 3 + 2];
207
+ const cx = aiy * bjz - aiz * bjy;
208
+ const cy = aiz * bjx - aix * bjz;
209
+ const cz = aix * bjy - aiy * bjx;
210
+ if (test_axis(cx, cy, cz, 6 + i * 3 + j)) return false;
211
+ }
212
+ }
213
+
214
+ // We have a contact. Output the normal.
215
+ const nx = best_nx, ny = best_ny, nz = best_nz;
216
+ out[0] = nx; out[1] = ny; out[2] = nz;
217
+
218
+ // ---- Edge-cross axis: closest-pair on the two involved edges ----
219
+ //
220
+ // When SAT identifies an edge-edge separating axis (source 6..14 =
221
+ // 6 + i*3 + j, where `i` is box A's local edge-axis index and
222
+ // `j` is box B's), the contact happens where one specific edge of
223
+ // A crosses (or is closest to) one specific edge of B. The earlier
224
+ // body-centre-midpoint fallback was sufficient for "we know they
225
+ // collide" but produced lever arms that confused the solver — for
226
+ // skewed-box stacks this led to slow drift.
227
+ //
228
+ // Procedure:
229
+ // 1. Decode (i, j) from `best_source`.
230
+ // 2. Among box A's 4 parallel edges along axis i, pick the one
231
+ // whose corner is most in the −n direction (closest to B).
232
+ // 3. Same for box B with +n direction.
233
+ // 4. `line3_closest_points_segment_segment` returns (s, t)
234
+ // parameters; reconstruct the world contact on each edge.
235
+ if (best_source >= 6) {
236
+ const ax_src = best_source - 6;
237
+ const i_a = (ax_src / 3) | 0;
238
+ const j_b = ax_src - i_a * 3;
239
+
240
+ // Edge directions in world.
241
+ const edge_a_dx = ta[i_a * 3];
242
+ const edge_a_dy = ta[i_a * 3 + 1];
243
+ const edge_a_dz = ta[i_a * 3 + 2];
244
+ const edge_b_dx = tb[j_b * 3];
245
+ const edge_b_dy = tb[j_b * 3 + 1];
246
+ const edge_b_dz = tb[j_b * 3 + 2];
247
+
248
+ // Edge half-extents (along the chosen axis).
249
+ const edge_a_half = i_a === 0 ? ahx : (i_a === 1 ? ahy : ahz);
250
+ const edge_b_half = j_b === 0 ? bhx : (j_b === 1 ? bhy : bhz);
251
+
252
+ // Perpendicular axes (the other two) and their half-extents.
253
+ let u_a_idx, v_a_idx;
254
+ if (i_a === 0) { u_a_idx = 1; v_a_idx = 2; }
255
+ else if (i_a === 1) { u_a_idx = 2; v_a_idx = 0; }
256
+ else { u_a_idx = 0; v_a_idx = 1; }
257
+ const u_a_x = ta[u_a_idx * 3], u_a_y = ta[u_a_idx * 3 + 1], u_a_z = ta[u_a_idx * 3 + 2];
258
+ const v_a_x = ta[v_a_idx * 3], v_a_y = ta[v_a_idx * 3 + 1], v_a_z = ta[v_a_idx * 3 + 2];
259
+ const half_u_a = u_a_idx === 0 ? ahx : (u_a_idx === 1 ? ahy : ahz);
260
+ const half_v_a = v_a_idx === 0 ? ahx : (v_a_idx === 1 ? ahy : ahz);
261
+
262
+ let u_b_idx, v_b_idx;
263
+ if (j_b === 0) { u_b_idx = 1; v_b_idx = 2; }
264
+ else if (j_b === 1) { u_b_idx = 2; v_b_idx = 0; }
265
+ else { u_b_idx = 0; v_b_idx = 1; }
266
+ const u_b_x = tb[u_b_idx * 3], u_b_y = tb[u_b_idx * 3 + 1], u_b_z = tb[u_b_idx * 3 + 2];
267
+ const v_b_x = tb[v_b_idx * 3], v_b_y = tb[v_b_idx * 3 + 1], v_b_z = tb[v_b_idx * 3 + 2];
268
+ const half_u_b = u_b_idx === 0 ? bhx : (u_b_idx === 1 ? bhy : bhz);
269
+ const half_v_b = v_b_idx === 0 ? bhx : (v_b_idx === 1 ? bhy : bhz);
270
+
271
+ // The contact normal `n` (= best_n) points B → A. From A's
272
+ // perspective B is in the −n direction; pick the A-corner most
273
+ // in that direction. From B's perspective A is in +n; pick the
274
+ // B-corner most in +n.
275
+ const minus_n_dot_u_a = -(nx * u_a_x + ny * u_a_y + nz * u_a_z);
276
+ const minus_n_dot_v_a = -(nx * v_a_x + ny * v_a_y + nz * v_a_z);
277
+ const u_sign_a = minus_n_dot_u_a >= 0 ? 1 : -1;
278
+ const v_sign_a = minus_n_dot_v_a >= 0 ? 1 : -1;
279
+
280
+ const plus_n_dot_u_b = nx * u_b_x + ny * u_b_y + nz * u_b_z;
281
+ const plus_n_dot_v_b = nx * v_b_x + ny * v_b_y + nz * v_b_z;
282
+ const u_sign_b = plus_n_dot_u_b >= 0 ? 1 : -1;
283
+ const v_sign_b = plus_n_dot_v_b >= 0 ? 1 : -1;
284
+
285
+ // Box-A edge centre = A_centre + u_sign_a * half_u_a * u_a
286
+ // + v_sign_a * half_v_a * v_a.
287
+ const corner_a_cx = ax + u_a_x * u_sign_a * half_u_a + v_a_x * v_sign_a * half_v_a;
288
+ const corner_a_cy = ay + u_a_y * u_sign_a * half_u_a + v_a_y * v_sign_a * half_v_a;
289
+ const corner_a_cz = az + u_a_z * u_sign_a * half_u_a + v_a_z * v_sign_a * half_v_a;
290
+ const edge_a_p1_x = corner_a_cx - edge_a_dx * edge_a_half;
291
+ const edge_a_p1_y = corner_a_cy - edge_a_dy * edge_a_half;
292
+ const edge_a_p1_z = corner_a_cz - edge_a_dz * edge_a_half;
293
+ const edge_a_p2_x = corner_a_cx + edge_a_dx * edge_a_half;
294
+ const edge_a_p2_y = corner_a_cy + edge_a_dy * edge_a_half;
295
+ const edge_a_p2_z = corner_a_cz + edge_a_dz * edge_a_half;
296
+
297
+ const corner_b_cx = bx + u_b_x * u_sign_b * half_u_b + v_b_x * v_sign_b * half_v_b;
298
+ const corner_b_cy = by + u_b_y * u_sign_b * half_u_b + v_b_y * v_sign_b * half_v_b;
299
+ const corner_b_cz = bz + u_b_z * u_sign_b * half_u_b + v_b_z * v_sign_b * half_v_b;
300
+ const edge_b_p1_x = corner_b_cx - edge_b_dx * edge_b_half;
301
+ const edge_b_p1_y = corner_b_cy - edge_b_dy * edge_b_half;
302
+ const edge_b_p1_z = corner_b_cz - edge_b_dz * edge_b_half;
303
+ const edge_b_p2_x = corner_b_cx + edge_b_dx * edge_b_half;
304
+ const edge_b_p2_y = corner_b_cy + edge_b_dy * edge_b_half;
305
+ const edge_b_p2_z = corner_b_cz + edge_b_dz * edge_b_half;
306
+
307
+ line3_closest_points_segment_segment(
308
+ scratch_edge_st,
309
+ edge_a_p1_x, edge_a_p1_y, edge_a_p1_z, edge_a_p2_x, edge_a_p2_y, edge_a_p2_z,
310
+ edge_b_p1_x, edge_b_p1_y, edge_b_p1_z, edge_b_p2_x, edge_b_p2_y, edge_b_p2_z
311
+ );
312
+ const s = scratch_edge_st[0];
313
+ const t = scratch_edge_st[1];
314
+ const contact_a_x = edge_a_p1_x + s * (edge_a_p2_x - edge_a_p1_x);
315
+ const contact_a_y = edge_a_p1_y + s * (edge_a_p2_y - edge_a_p1_y);
316
+ const contact_a_z = edge_a_p1_z + s * (edge_a_p2_z - edge_a_p1_z);
317
+ const contact_b_x = edge_b_p1_x + t * (edge_b_p2_x - edge_b_p1_x);
318
+ const contact_b_y = edge_b_p1_y + t * (edge_b_p2_y - edge_b_p1_y);
319
+ const contact_b_z = edge_b_p1_z + t * (edge_b_p2_z - edge_b_p1_z);
320
+
321
+ out[3] = 1;
322
+ out[4] = contact_a_x; out[5] = contact_a_y; out[6] = contact_a_z;
323
+ out[7] = contact_b_x; out[8] = contact_b_y; out[9] = contact_b_z;
324
+ out[10] = best_overlap;
325
+ return true;
326
+ }
327
+
328
+ // ---- Face axis: face clipping ----
329
+ // Determine reference and incident.
330
+ const ref_is_A = best_source < 3;
331
+ // Reference axis index in the owning box (0..2).
332
+ const ref_axis_idx = ref_is_A ? best_source : best_source - 3;
333
+
334
+ // Reference box pose.
335
+ const ref_axes = ref_is_A ? ta : tb;
336
+ const inc_axes = ref_is_A ? tb : ta;
337
+ const ref_h_x = ref_is_A ? ahx : bhx;
338
+ const ref_h_y = ref_is_A ? ahy : bhy;
339
+ const ref_h_z = ref_is_A ? ahz : bhz;
340
+ const inc_h_x = ref_is_A ? bhx : ahx;
341
+ const inc_h_y = ref_is_A ? bhy : ahy;
342
+ const inc_h_z = ref_is_A ? bhz : ahz;
343
+ const ref_cx = ref_is_A ? ax : bx;
344
+ const ref_cy = ref_is_A ? ay : by;
345
+ const ref_cz = ref_is_A ? az : bz;
346
+ const inc_cx = ref_is_A ? bx : ax;
347
+ const inc_cy = ref_is_A ? by : ay;
348
+ const inc_cz = ref_is_A ? bz : az;
349
+
350
+ // Reference face outward normal in world: the face of the ref box facing
351
+ // the incident box. The contact normal points B→A; the ref face's
352
+ // outward normal must point toward the incident box (= -n if ref is A,
353
+ // = +n if ref is B).
354
+ const ref_out_nx = ref_is_A ? -nx : nx;
355
+ const ref_out_ny = ref_is_A ? -ny : ny;
356
+ const ref_out_nz = ref_is_A ? -nz : nz;
357
+
358
+ // Ref face's three axis-in-world directions: the axis-direction matching
359
+ // ref_axis_idx is the OUTWARD normal; the other two are the face tangents.
360
+ // Sign of the reference-face axis aligned with ref_out:
361
+ const ref_axis_world_x = ref_axes[ref_axis_idx * 3];
362
+ const ref_axis_world_y = ref_axes[ref_axis_idx * 3 + 1];
363
+ const ref_axis_world_z = ref_axes[ref_axis_idx * 3 + 2];
364
+ const ref_axis_dot = ref_axis_world_x * ref_out_nx
365
+ + ref_axis_world_y * ref_out_ny
366
+ + ref_axis_world_z * ref_out_nz;
367
+ const ref_axis_sign = ref_axis_dot >= 0 ? 1 : -1;
368
+
369
+ // Face plane: passes through `ref_cx + ref_axis * ref_axis_sign * ref_h_<axis>`,
370
+ // with outward normal = `ref_axis_world * ref_axis_sign`.
371
+ const ref_h_along_axis = ref_axis_idx === 0 ? ref_h_x : (ref_axis_idx === 1 ? ref_h_y : ref_h_z);
372
+ const ref_face_origin_x = ref_cx + ref_axis_world_x * ref_axis_sign * ref_h_along_axis;
373
+ const ref_face_origin_y = ref_cy + ref_axis_world_y * ref_axis_sign * ref_h_along_axis;
374
+ const ref_face_origin_z = ref_cz + ref_axis_world_z * ref_axis_sign * ref_h_along_axis;
375
+
376
+ // Reference face's two tangent axes (u, v) in world, with the corresponding half-extents.
377
+ let u_axis_idx, v_axis_idx;
378
+ if (ref_axis_idx === 0) { u_axis_idx = 1; v_axis_idx = 2; }
379
+ else if (ref_axis_idx === 1) { u_axis_idx = 2; v_axis_idx = 0; }
380
+ else { u_axis_idx = 0; v_axis_idx = 1; }
381
+
382
+ const ux = ref_axes[u_axis_idx * 3], uy = ref_axes[u_axis_idx * 3 + 1], uz = ref_axes[u_axis_idx * 3 + 2];
383
+ const vx = ref_axes[v_axis_idx * 3], vy = ref_axes[v_axis_idx * 3 + 1], vz = ref_axes[v_axis_idx * 3 + 2];
384
+ const half_u = u_axis_idx === 0 ? ref_h_x : (u_axis_idx === 1 ? ref_h_y : ref_h_z);
385
+ const half_v = v_axis_idx === 0 ? ref_h_x : (v_axis_idx === 1 ? ref_h_y : ref_h_z);
386
+
387
+ // ---- Pick incident face on the OTHER box ----
388
+ // Its outward normal should be MOST antiparallel to the ref face outward normal
389
+ // (i.e., the face of the incident box that is "looking back" at the ref face).
390
+ let inc_axis_idx = 0, inc_axis_sign = 1;
391
+ let max_anti = -Infinity;
392
+ for (let i = 0; i < 3; i++) {
393
+ const iax = inc_axes[i * 3], iay = inc_axes[i * 3 + 1], iaz = inc_axes[i * 3 + 2];
394
+ const d_pos = iax * ref_out_nx + iay * ref_out_ny + iaz * ref_out_nz;
395
+ // We want dot ≈ -1, so most negative dot is the most anti-parallel
396
+ if (-d_pos > max_anti) { max_anti = -d_pos; inc_axis_idx = i; inc_axis_sign = -1; }
397
+ if ( d_pos > max_anti) { max_anti = d_pos; inc_axis_idx = i; inc_axis_sign = 1; }
398
+ }
399
+ // Now the incident face outward normal must be antiparallel to ref_out_n.
400
+ // We chose inc_axis_sign as the sign of dot(inc_axis_dir, ref_out_n). The
401
+ // incident face's outward direction is the OPPOSITE sign (facing back at ref).
402
+ const inc_outward_sign = -inc_axis_sign;
403
+
404
+ const inc_h_along_axis = inc_axis_idx === 0 ? inc_h_x : (inc_axis_idx === 1 ? inc_h_y : inc_h_z);
405
+ // Incident face centre in world.
406
+ const inc_face_cx = inc_cx + inc_axes[inc_axis_idx * 3] * inc_outward_sign * inc_h_along_axis;
407
+ const inc_face_cy = inc_cy + inc_axes[inc_axis_idx * 3 + 1] * inc_outward_sign * inc_h_along_axis;
408
+ const inc_face_cz = inc_cz + inc_axes[inc_axis_idx * 3 + 2] * inc_outward_sign * inc_h_along_axis;
409
+
410
+ // Incident face's two tangent axes in world, with their half-extents.
411
+ let i_u_idx, i_v_idx;
412
+ if (inc_axis_idx === 0) { i_u_idx = 1; i_v_idx = 2; }
413
+ else if (inc_axis_idx === 1) { i_u_idx = 2; i_v_idx = 0; }
414
+ else { i_u_idx = 0; i_v_idx = 1; }
415
+ const iux = inc_axes[i_u_idx * 3], iuy = inc_axes[i_u_idx * 3 + 1], iuz = inc_axes[i_u_idx * 3 + 2];
416
+ const ivx = inc_axes[i_v_idx * 3], ivy = inc_axes[i_v_idx * 3 + 1], ivz = inc_axes[i_v_idx * 3 + 2];
417
+ const i_half_u = i_u_idx === 0 ? inc_h_x : (i_u_idx === 1 ? inc_h_y : inc_h_z);
418
+ const i_half_v = i_v_idx === 0 ? inc_h_x : (i_v_idx === 1 ? inc_h_y : inc_h_z);
419
+
420
+ // Build incident face's 4 world corners (ordered CCW around the face).
421
+ const signs_u = [ 1, 1, -1, -1];
422
+ const signs_v = [-1, 1, 1, -1];
423
+ for (let i = 0; i < 4; i++) {
424
+ const su = signs_u[i] * i_half_u;
425
+ const sv = signs_v[i] * i_half_v;
426
+ incident_world[i * 3] = inc_face_cx + iux * su + ivx * sv;
427
+ incident_world[i * 3 + 1] = inc_face_cy + iuy * su + ivy * sv;
428
+ incident_world[i * 3 + 2] = inc_face_cz + iuz * su + ivz * sv;
429
+ }
430
+
431
+ // Project incident corners into ref-face uv coordinates.
432
+ // For each corner C: uv = ((C - ref_face_origin) · u_axis, ... · v_axis).
433
+ for (let i = 0; i < 4; i++) {
434
+ const ex = incident_world[i * 3] - ref_face_origin_x;
435
+ const ey = incident_world[i * 3 + 1] - ref_face_origin_y;
436
+ const ez = incident_world[i * 3 + 2] - ref_face_origin_z;
437
+ incident_uv[i * 2] = ex * ux + ey * uy + ez * uz;
438
+ incident_uv[i * 2 + 1] = ex * vx + ey * vy + ez * vz;
439
+ }
440
+
441
+ // Sutherland-Hodgman clip against the rectangle |u|<=half_u, |v|<=half_v.
442
+ // Apply 4 successive single-axis clips.
443
+ let n = 4;
444
+ // Copy into clipped_uv_in first.
445
+ for (let i = 0; i < n * 2; i++) clipped_uv_in[i] = incident_uv[i];
446
+
447
+ n = clip_against_axis(clipped_uv_in, n, clipped_uv_out, 0, half_u, true);
448
+ if (n === 0) return out_empty(out);
449
+ n = clip_against_axis(clipped_uv_out, n, clipped_uv_in, 0, -half_u, false);
450
+ if (n === 0) return out_empty(out);
451
+ n = clip_against_axis(clipped_uv_in, n, clipped_uv_out, 1, half_v, true);
452
+ if (n === 0) return out_empty(out);
453
+ n = clip_against_axis(clipped_uv_out, n, clipped_uv_in, 1, -half_v, false);
454
+ if (n === 0) return out_empty(out);
455
+
456
+ // Each surviving uv-point is on the ref face rectangle. We need to:
457
+ // 1. Map uv back to world → that's the contact point on the *incident* face
458
+ // (still on the inc face plane at that uv).
459
+ // 2. Compute depth = penetration along contact normal n (B→A).
460
+ // 3. The contact on the *reference* face is the projection of the inc-face
461
+ // point onto the reference plane along the contact normal.
462
+
463
+ // To re-derive the world position from a uv coord: we need to keep both the
464
+ // uv coord and the corresponding world point. But we just clipped uv-only,
465
+ // so the world position is the projection back. The depth resolves it:
466
+ //
467
+ // ref plane: normal = ref_outward, origin at ref_face_origin
468
+ // incident point world = ref_face_origin + u*u_axis + v*v_axis + (signed projection along ref_out)
469
+ //
470
+ // The component along ref_out for the original incident corner is what we lost
471
+ // by going to uv. We recompute it from the original incident face plane (which
472
+ // is at a fixed offset from ref): the inc corner's signed distance from the ref
473
+ // plane is `(corner - ref_face_origin) · ref_out_n`.
474
+ //
475
+ // After clipping in uv, we can't directly recover that distance without
476
+ // re-projecting onto the inc face plane. We do that here.
477
+
478
+ const ref_out_x = ref_axis_world_x * ref_axis_sign;
479
+ const ref_out_y = ref_axis_world_y * ref_axis_sign;
480
+ const ref_out_z = ref_axis_world_z * ref_axis_sign;
481
+
482
+ // Inc face plane (in world): point inc_face_c, normal inc_outward
483
+ // = inc_axes[inc_axis_idx*3..+2] * inc_outward_sign.
484
+ const inc_out_x = inc_axes[inc_axis_idx * 3] * inc_outward_sign;
485
+ const inc_out_y = inc_axes[inc_axis_idx * 3 + 1] * inc_outward_sign;
486
+ const inc_out_z = inc_axes[inc_axis_idx * 3 + 2] * inc_outward_sign;
487
+
488
+ // For a clipped uv point P_uv, the corresponding world point P_world on the
489
+ // incident face plane satisfies:
490
+ // P_world = ref_face_origin + u*u_axis + v*v_axis + t * ref_out for some t
491
+ // (P_world - inc_face_c) · inc_out = 0
492
+ // Substitute and solve for t. Let:
493
+ // X = ref_face_origin + u*u_axis + v*v_axis (a point on the line)
494
+ // t such that (X + t*ref_out - inc_face_c) · inc_out = 0
495
+ // t * (ref_out · inc_out) = (inc_face_c - X) · inc_out
496
+ const ref_dot_inc = ref_out_x * inc_out_x + ref_out_y * inc_out_y + ref_out_z * inc_out_z;
497
+ // Faces are nearly parallel → ref_dot_inc ≈ -1 (anti-parallel). Robust.
498
+
499
+ // Build candidates: for each clipped uv point.
500
+ let cand_count = 0;
501
+ const clipped_uv = clipped_uv_in;
502
+ for (let i = 0; i < n; i++) {
503
+ const u = clipped_uv[i * 2];
504
+ const v = clipped_uv[i * 2 + 1];
505
+
506
+ const x_x = ref_face_origin_x + u * ux + v * vx;
507
+ const x_y = ref_face_origin_y + u * uy + v * vy;
508
+ const x_z = ref_face_origin_z + u * uz + v * vz;
509
+
510
+ let world_inc_x, world_inc_y, world_inc_z;
511
+ if (ref_dot_inc !== 0) {
512
+ const num_x = inc_face_cx - x_x;
513
+ const num_y = inc_face_cy - x_y;
514
+ const num_z = inc_face_cz - x_z;
515
+ const t = (num_x * inc_out_x + num_y * inc_out_y + num_z * inc_out_z) / ref_dot_inc;
516
+ world_inc_x = x_x + ref_out_x * t;
517
+ world_inc_y = x_y + ref_out_y * t;
518
+ world_inc_z = x_z + ref_out_z * t;
519
+ } else {
520
+ // Faces orthogonal — degenerate, fall back to uv point on ref plane.
521
+ world_inc_x = x_x; world_inc_y = x_y; world_inc_z = x_z;
522
+ }
523
+
524
+ // Penetration: signed distance of inc-face contact from the ref plane,
525
+ // measured into the ref box (= along -ref_out). Positive means penetrating.
526
+ const sep_x = world_inc_x - ref_face_origin_x;
527
+ const sep_y = world_inc_y - ref_face_origin_y;
528
+ const sep_z = world_inc_z - ref_face_origin_z;
529
+ const sep_along_ref_out = sep_x * ref_out_x + sep_y * ref_out_y + sep_z * ref_out_z;
530
+ const depth = -sep_along_ref_out;
531
+ if (depth < 0) continue;
532
+
533
+ candidates[cand_count * 4] = world_inc_x;
534
+ candidates[cand_count * 4 + 1] = world_inc_y;
535
+ candidates[cand_count * 4 + 2] = world_inc_z;
536
+ candidates[cand_count * 4 + 3] = depth;
537
+ cand_count++;
538
+ }
539
+
540
+ if (cand_count === 0) return out_empty(out);
541
+
542
+ // ---- Reduce to ≤ MAX_CONTACTS by best-deepest + perimeter ----
543
+ const kept = reduce_contacts(cand_count);
544
+
545
+ // ---- Emit: contact-on-incident is the candidate's world point;
546
+ // contact-on-reference is the same point projected onto the ref plane.
547
+ out[3] = kept;
548
+ for (let k = 0; k < kept; k++) {
549
+ const px = candidates[k * 4];
550
+ const py = candidates[k * 4 + 1];
551
+ const pz = candidates[k * 4 + 2];
552
+ const depth = candidates[k * 4 + 3];
553
+
554
+ // ref-side contact = project onto ref plane along ref_out.
555
+ const dist_to_plane = (px - ref_face_origin_x) * ref_out_x
556
+ + (py - ref_face_origin_y) * ref_out_y
557
+ + (pz - ref_face_origin_z) * ref_out_z;
558
+ const rpx = px - ref_out_x * dist_to_plane;
559
+ const rpy = py - ref_out_y * dist_to_plane;
560
+ const rpz = pz - ref_out_z * dist_to_plane;
561
+
562
+ let wax, way, waz, wbx_, wby_, wbz_;
563
+ if (ref_is_A) {
564
+ wax = rpx; way = rpy; waz = rpz;
565
+ wbx_ = px; wby_ = py; wbz_ = pz;
566
+ } else {
567
+ wax = px; way = py; waz = pz;
568
+ wbx_ = rpx; wby_ = rpy; wbz_ = rpz;
569
+ }
570
+
571
+ const base = 4 + k * CONTACT_STRIDE;
572
+ out[base] = wax; out[base + 1] = way; out[base + 2] = waz;
573
+ out[base + 3] = wbx_; out[base + 4] = wby_; out[base + 5] = wbz_;
574
+ out[base + 6] = depth;
575
+ }
576
+ return true;
577
+ }
578
+
579
+ function out_empty(out) {
580
+ out[3] = 0;
581
+ return true; // overlap exists per SAT, just no clipped manifold
582
+ }
583
+
584
+ /**
585
+ * In-place reduction of `candidates` to at most {@link MAX_CONTACTS}:
586
+ * 1. Sort by depth descending; deepest stays at index 0.
587
+ * 2. From the remaining, greedily pick the points that maximise the spread
588
+ * (sum of squared distances to already-kept points). This approximates
589
+ * the maximum-area heuristic without needing the actual area.
590
+ *
591
+ * @param {number} n input count
592
+ * @returns {number} kept count (min(n, MAX_CONTACTS))
593
+ */
594
+ function reduce_contacts(n) {
595
+ if (n <= MAX_CONTACTS) return n;
596
+
597
+ // Find deepest, swap into slot 0.
598
+ let deepest_idx = 0;
599
+ let deepest_val = candidates[3];
600
+ for (let i = 1; i < n; i++) {
601
+ if (candidates[i * 4 + 3] > deepest_val) {
602
+ deepest_val = candidates[i * 4 + 3];
603
+ deepest_idx = i;
604
+ }
605
+ }
606
+ if (deepest_idx !== 0) swap_candidate(0, deepest_idx);
607
+
608
+ // Greedy: for slot k in 1..MAX_CONTACTS-1, pick the remaining candidate
609
+ // whose min-distance-sq-to-already-kept-set is largest.
610
+ for (let k = 1; k < MAX_CONTACTS; k++) {
611
+ let best_score = -1;
612
+ let best_i = -1;
613
+ for (let i = k; i < n; i++) {
614
+ let min_d2 = Infinity;
615
+ for (let j = 0; j < k; j++) {
616
+ const dx = candidates[i * 4] - candidates[j * 4];
617
+ const dy = candidates[i * 4 + 1] - candidates[j * 4 + 1];
618
+ const dz = candidates[i * 4 + 2] - candidates[j * 4 + 2];
619
+ const d2 = dx * dx + dy * dy + dz * dz;
620
+ if (d2 < min_d2) min_d2 = d2;
621
+ }
622
+ if (min_d2 > best_score) { best_score = min_d2; best_i = i; }
623
+ }
624
+ if (best_i !== k) swap_candidate(k, best_i);
625
+ }
626
+ return MAX_CONTACTS;
627
+ }
628
+
629
+ function swap_candidate(a, b) {
630
+ const ax = candidates[a * 4], ay = candidates[a * 4 + 1], az = candidates[a * 4 + 2], ad = candidates[a * 4 + 3];
631
+ candidates[a * 4] = candidates[b * 4];
632
+ candidates[a * 4 + 1] = candidates[b * 4 + 1];
633
+ candidates[a * 4 + 2] = candidates[b * 4 + 2];
634
+ candidates[a * 4 + 3] = candidates[b * 4 + 3];
635
+ candidates[b * 4] = ax;
636
+ candidates[b * 4 + 1] = ay;
637
+ candidates[b * 4 + 2] = az;
638
+ candidates[b * 4 + 3] = ad;
639
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @param {number[]|Float64Array} out length >= {@link BOX_TRIANGLE_OUT_LENGTH}
3
+ * @param {number} bcx box centre x (world)
4
+ * @param {number} bcy
5
+ * @param {number} bcz
6
+ * @param {number} bqx box quaternion x
7
+ * @param {number} bqy
8
+ * @param {number} bqz
9
+ * @param {number} bqw
10
+ * @param {number} bhx box half-extent x (body frame)
11
+ * @param {number} bhy
12
+ * @param {number} bhz
13
+ * @param {number} ax triangle vertex A x (world)
14
+ * @param {number} ay
15
+ * @param {number} az
16
+ * @param {number} bx triangle vertex B x (world)
17
+ * @param {number} by
18
+ * @param {number} bz
19
+ * @param {number} cx triangle vertex C x (world)
20
+ * @param {number} cy
21
+ * @param {number} cz
22
+ * @returns {boolean} true if box and triangle overlap
23
+ */
24
+ export function box_triangle_contact(out: number[] | Float64Array, bcx: number, bcy: number, bcz: number, bqx: number, bqy: number, bqz: number, bqw: number, bhx: number, bhy: number, bhz: number, ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): boolean;
25
+ /**
26
+ * Length of `out` required by {@link box_triangle_contact}.
27
+ * @type {number}
28
+ */
29
+ export const BOX_TRIANGLE_OUT_LENGTH: number;
30
+ //# sourceMappingURL=box_triangle_contact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"box_triangle_contact.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/narrowphase/box_triangle_contact.js"],"names":[],"mappings":"AAuNA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,0CAtBW,MAAM,EAAE,GAAC,YAAY,OACrB,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,OAAO,CAuJnB;AAxUD;;;GAGG;AACH,sCAFU,MAAM,CAEyD"}