@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,122 @@
1
+ /**
2
+ * Compute the two world endpoints of a capsule's central segment given its
3
+ * pose. The capsule is Y-aligned in body frame; the segment runs from
4
+ * `(0, -h/2, 0)` to `(0, +h/2, 0)`. Writes endpoints into `out` as
5
+ * `[ax, ay, az, bx, by, bz]`.
6
+ *
7
+ * @param {number[]|Float64Array} out length >= 6
8
+ * @param {number} cx capsule centre x
9
+ * @param {number} cy
10
+ * @param {number} cz
11
+ * @param {number} qx quaternion x
12
+ * @param {number} qy
13
+ * @param {number} qz
14
+ * @param {number} qw
15
+ * @param {number} half_height
16
+ */
17
+ export function capsule_world_segment(out: number[] | Float64Array, cx: number, cy: number, cz: number, qx: number, qy: number, qz: number, qw: number, half_height: number): void;
18
+ /**
19
+ * Capsule (A) vs sphere (B) contact, closed-form via point-segment distance.
20
+ *
21
+ * @param {number[]|Float64Array} out length >= 10
22
+ * @param {number} a_cx capsule centre x
23
+ * @param {number} a_cy
24
+ * @param {number} a_cz
25
+ * @param {number} a_qx capsule rotation
26
+ * @param {number} a_qy
27
+ * @param {number} a_qz
28
+ * @param {number} a_qw
29
+ * @param {number} a_radius
30
+ * @param {number} a_half_h capsule half-height (not including caps)
31
+ * @param {number} b_cx sphere centre x
32
+ * @param {number} b_cy
33
+ * @param {number} b_cz
34
+ * @param {number} b_radius
35
+ * @returns {boolean} true on overlap
36
+ */
37
+ export function capsule_sphere_contact(out: number[] | Float64Array, a_cx: number, a_cy: number, a_cz: number, a_qx: number, a_qy: number, a_qz: number, a_qw: number, a_radius: number, a_half_h: number, b_cx: number, b_cy: number, b_cz: number, b_radius: number): boolean;
38
+ /**
39
+ * Two capsules (A and B). Reduces to segment-segment closest pair + radius.
40
+ *
41
+ * @param {number[]|Float64Array} out length >= 10
42
+ * @returns {boolean} true on overlap
43
+ */
44
+ export function capsule_capsule_contact(out: number[] | Float64Array, a_cx: any, a_cy: any, a_cz: any, a_qx: any, a_qy: any, a_qz: any, a_qw: any, a_radius: any, a_half_h: any, b_cx: any, b_cy: any, b_cz: any, b_qx: any, b_qy: any, b_qz: any, b_qw: any, b_radius: any, b_half_h: any): boolean;
45
+ /**
46
+ * Capsule (A) vs oriented box (B). Brings the capsule segment into box-local
47
+ * space, then refines via 2 fixed-point iterations between:
48
+ * - closest point on the segment to the current box-side candidate
49
+ * - clamped point on the box closest to the current segment-side candidate
50
+ *
51
+ * Two iterations suffice for the cases this engine targets (sphere-like cap
52
+ * geometry against axis-aligned-in-local box). When the segment passes
53
+ * through the box, the "inside" branch picks the smallest-overlap face
54
+ * deterministically, mirroring {@link sphere_box_contact}.
55
+ *
56
+ * @param {number[]|Float64Array} out length >= 10
57
+ * @returns {boolean}
58
+ */
59
+ export function capsule_box_contact(out: number[] | Float64Array, a_cx: any, a_cy: any, a_cz: any, a_qx: any, a_qy: any, a_qz: any, a_qw: any, a_radius: any, a_half_h: any, b_cx: any, b_cy: any, b_cz: any, b_qx: any, b_qy: any, b_qz: any, b_qw: any, b_hx: any, b_hy: any, b_hz: any): boolean;
60
+ /**
61
+ * Multi-point capsule-vs-OBB contact generation. Emits up to
62
+ * {@link CAPSULE_BOX_MAX_CONTACTS} contacts into `out` in the
63
+ * `(wax, way, waz, wbx, wby, wbz, nx, ny, nz, depth)` stride layout.
64
+ *
65
+ * The motivation: a capsule lying flat on a face needs more than one
66
+ * contact to rest stably — a single contact at the segment's closest point
67
+ * is positionally ambiguous (every interior segment point is equidistant
68
+ * from the face), and the body wobbles around whichever point the
69
+ * iterative closest-point solver happened to converge on. Two contacts at
70
+ * the cap centres pin the capsule's rotation about its long axis.
71
+ *
72
+ * Algorithm:
73
+ * 1. Closest-point-on-segment vs OBB → primary contact (same as
74
+ * {@link capsule_box_contact}).
75
+ * 2. Treat each cap centre as a sphere of cap-radius and run
76
+ * {@link sphere_box_contact} → up to two additional contacts.
77
+ * 3. Dedupe spatially against the primary so a capsule touching with one
78
+ * cap doesn't emit two contacts at the same point.
79
+ *
80
+ * @param {Float64Array} out length >= CAPSULE_BOX_MAX_CONTACTS * CAPSULE_BOX_CONTACT_STRIDE
81
+ * @param {number} a_cx capsule centre x
82
+ * @param {number} a_cy
83
+ * @param {number} a_cz
84
+ * @param {number} a_qx capsule rotation
85
+ * @param {number} a_qy
86
+ * @param {number} a_qz
87
+ * @param {number} a_qw
88
+ * @param {number} a_radius
89
+ * @param {number} a_half_h
90
+ * @param {number} b_cx box centre x
91
+ * @param {number} b_cy
92
+ * @param {number} b_cz
93
+ * @param {number} b_qx
94
+ * @param {number} b_qy
95
+ * @param {number} b_qz
96
+ * @param {number} b_qw
97
+ * @param {number} b_hx
98
+ * @param {number} b_hy
99
+ * @param {number} b_hz
100
+ * @returns {number} number of contacts emitted, in `[0, CAPSULE_BOX_MAX_CONTACTS]`
101
+ */
102
+ export function capsule_box_multi_contacts(out: Float64Array, a_cx: number, a_cy: number, a_cz: number, a_qx: number, a_qy: number, a_qz: number, a_qw: number, a_radius: number, a_half_h: number, b_cx: number, b_cy: number, b_cz: number, b_qx: number, b_qy: number, b_qz: number, b_qw: number, b_hx: number, b_hy: number, b_hz: number): number;
103
+ /**
104
+ * Output stride per contact in {@link capsule_box_multi_contacts}.
105
+ * Matches the candidate-buffer layout used by `narrowphase_step`.
106
+ *
107
+ * 0..2 : world contact on capsule side
108
+ * 3..5 : world contact on box side
109
+ * 6..8 : normal from box (B) toward capsule (A)
110
+ * 9 : depth (positive = penetration)
111
+ *
112
+ * @type {number}
113
+ */
114
+ export const CAPSULE_BOX_CONTACT_STRIDE: number;
115
+ /**
116
+ * Maximum contact points {@link capsule_box_multi_contacts} can emit.
117
+ * - 1 from the closest-point-on-segment vs OBB query (primary)
118
+ * - up to 2 from the cap-centre sphere-vs-OBB queries (one per endpoint)
119
+ * @type {number}
120
+ */
121
+ export const CAPSULE_BOX_MAX_CONTACTS: number;
122
+ //# sourceMappingURL=capsule_contacts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capsule_contacts.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/narrowphase/capsule_contacts.js"],"names":[],"mappings":"AA4BA;;;;;;;;;;;;;;;GAeG;AACH,2CAVW,MAAM,EAAE,GAAC,YAAY,MACrB,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,eACN,MAAM,QAOhB;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,4CAhBW,MAAM,EAAE,GAAC,YAAY,QACrB,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,YACN,MAAM,YACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,YACN,MAAM,GACJ,OAAO,CA6CnB;AAMD;;;;;GAKG;AACH,6CAHW,MAAM,EAAE,GAAC,YAAY,yNACnB,OAAO,CAuEnB;AAOD;;;;;;;;;;;;;GAaG;AACH,yCAHW,MAAM,EAAE,GAAC,YAAY,4NACnB,OAAO,CA8FnB;AAyCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,gDAtBW,YAAY,QACZ,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,YACN,MAAM,YACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,GACJ,MAAM,CAuElB;AApJD;;;;;;;;;;GAUG;AACH,yCAFU,MAAM,CAE6B;AAE7C;;;;;GAKG;AACH,uCAFU,MAAM,CAE0B"}
@@ -0,0 +1,462 @@
1
+ import { line3_closest_points_segment_segment } from "../../../core/geom/3d/line/line3_closest_points_segment_segment.js";
2
+ import { line3_compute_segment_nearest_point_to_point_t } from "../../../core/geom/3d/line/line3_compute_segment_nearest_point_to_point_t.js";
3
+ import { v3_quat3_apply } from "../../../core/geom/vec3/v3_quat3_apply.js";
4
+ import { v3_quat3_apply_inverse } from "../../../core/geom/vec3/v3_quat3_apply_inverse.js";
5
+ import { sphere_box_contact } from "./sphere_box_contact.js";
6
+
7
+ /**
8
+ * Closed-form narrowphase helpers for the capsule family. A capsule is the
9
+ * Minkowski sum of a line segment and a sphere of radius `r`, so contact
10
+ * resolution reduces to:
11
+ * - capsule-sphere → point-on-segment distance, then sphere-style normal
12
+ * - capsule-capsule → segment-segment closest pair
13
+ * - capsule-box → segment-vs-OBB closest point (iterative)
14
+ *
15
+ * Output convention (matches the rest of the narrowphase family):
16
+ * out[0..2] : normal pointing from B toward A
17
+ * out[3] : penetration depth (positive)
18
+ * out[4..6] : world contact on A's surface
19
+ * out[7..9] : world contact on B's surface
20
+ *
21
+ * @author Alex Goldring
22
+ * @copyright Company Named Limited (c) 2026
23
+ */
24
+
25
+ const scratch_st = new Float64Array(2);
26
+
27
+ const scratch_seg = new Float64Array(6);
28
+
29
+ /**
30
+ * Compute the two world endpoints of a capsule's central segment given its
31
+ * pose. The capsule is Y-aligned in body frame; the segment runs from
32
+ * `(0, -h/2, 0)` to `(0, +h/2, 0)`. Writes endpoints into `out` as
33
+ * `[ax, ay, az, bx, by, bz]`.
34
+ *
35
+ * @param {number[]|Float64Array} out length >= 6
36
+ * @param {number} cx capsule centre x
37
+ * @param {number} cy
38
+ * @param {number} cz
39
+ * @param {number} qx quaternion x
40
+ * @param {number} qy
41
+ * @param {number} qz
42
+ * @param {number} qw
43
+ * @param {number} half_height
44
+ */
45
+ export function capsule_world_segment(out, cx, cy, cz, qx, qy, qz, qw, half_height) {
46
+ v3_quat3_apply(out, 0, 0, -half_height, 0, qx, qy, qz, qw);
47
+ v3_quat3_apply(out, 3, 0, half_height, 0, qx, qy, qz, qw);
48
+ out[0] += cx; out[1] += cy; out[2] += cz;
49
+ out[3] += cx; out[4] += cy; out[5] += cz;
50
+ }
51
+
52
+ // --- capsule vs sphere ------------------------------------------------------
53
+
54
+ /**
55
+ * Capsule (A) vs sphere (B) contact, closed-form via point-segment distance.
56
+ *
57
+ * @param {number[]|Float64Array} out length >= 10
58
+ * @param {number} a_cx capsule centre x
59
+ * @param {number} a_cy
60
+ * @param {number} a_cz
61
+ * @param {number} a_qx capsule rotation
62
+ * @param {number} a_qy
63
+ * @param {number} a_qz
64
+ * @param {number} a_qw
65
+ * @param {number} a_radius
66
+ * @param {number} a_half_h capsule half-height (not including caps)
67
+ * @param {number} b_cx sphere centre x
68
+ * @param {number} b_cy
69
+ * @param {number} b_cz
70
+ * @param {number} b_radius
71
+ * @returns {boolean} true on overlap
72
+ */
73
+ export function capsule_sphere_contact(
74
+ out,
75
+ a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
76
+ b_cx, b_cy, b_cz, b_radius
77
+ ) {
78
+ capsule_world_segment(scratch_seg, a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_half_h);
79
+ const sax = scratch_seg[0], say = scratch_seg[1], saz = scratch_seg[2];
80
+ const sbx = scratch_seg[3], sby = scratch_seg[4], sbz = scratch_seg[5];
81
+
82
+ const t = line3_compute_segment_nearest_point_to_point_t(sax, say, saz, sbx, sby, sbz, b_cx, b_cy, b_cz);
83
+
84
+ const px = sax + (sbx - sax) * t;
85
+ const py = say + (sby - say) * t;
86
+ const pz = saz + (sbz - saz) * t;
87
+
88
+ const dx = px - b_cx;
89
+ const dy = py - b_cy;
90
+ const dz = pz - b_cz;
91
+ const dist_sqr = dx * dx + dy * dy + dz * dz;
92
+ const sum = a_radius + b_radius;
93
+ if (dist_sqr >= sum * sum) return false;
94
+
95
+ const dist = Math.sqrt(dist_sqr);
96
+ let nx, ny, nz;
97
+ if (dist > 0) {
98
+ const inv = 1 / dist;
99
+ nx = dx * inv; ny = dy * inv; nz = dz * inv;
100
+ } else {
101
+ // Sphere centre exactly on the capsule segment — pick a deterministic tie-break.
102
+ nx = 1; ny = 0; nz = 0;
103
+ }
104
+
105
+ out[0] = nx; out[1] = ny; out[2] = nz; // normal from B to A
106
+ out[3] = sum - dist;
107
+ // World contact on A (capsule): segment point pushed back by capsule radius along -normal
108
+ out[4] = px - nx * a_radius;
109
+ out[5] = py - ny * a_radius;
110
+ out[6] = pz - nz * a_radius;
111
+ // World contact on B (sphere): sphere centre pushed along +normal by sphere radius
112
+ out[7] = b_cx + nx * b_radius;
113
+ out[8] = b_cy + ny * b_radius;
114
+ out[9] = b_cz + nz * b_radius;
115
+ return true;
116
+ }
117
+
118
+ // --- capsule vs capsule -----------------------------------------------------
119
+
120
+ const scratch_seg_b = new Float64Array(6);
121
+
122
+ /**
123
+ * Two capsules (A and B). Reduces to segment-segment closest pair + radius.
124
+ *
125
+ * @param {number[]|Float64Array} out length >= 10
126
+ * @returns {boolean} true on overlap
127
+ */
128
+ export function capsule_capsule_contact(
129
+ out,
130
+ a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
131
+ b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_radius, b_half_h
132
+ ) {
133
+ capsule_world_segment(scratch_seg, a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_half_h);
134
+ capsule_world_segment(scratch_seg_b, b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_half_h);
135
+
136
+ const a0x = scratch_seg[0], a0y = scratch_seg[1], a0z = scratch_seg[2];
137
+ const a1x = scratch_seg[3], a1y = scratch_seg[4], a1z = scratch_seg[5];
138
+ const b0x = scratch_seg_b[0], b0y = scratch_seg_b[1], b0z = scratch_seg_b[2];
139
+ const b1x = scratch_seg_b[3], b1y = scratch_seg_b[4], b1z = scratch_seg_b[5];
140
+
141
+ line3_closest_points_segment_segment(
142
+ scratch_st,
143
+ a0x, a0y, a0z, a1x, a1y, a1z,
144
+ b0x, b0y, b0z, b1x, b1y, b1z
145
+ );
146
+
147
+ const s = scratch_st[0];
148
+ const t = scratch_st[1];
149
+
150
+ const pax = a0x + (a1x - a0x) * s;
151
+ const pay = a0y + (a1y - a0y) * s;
152
+ const paz = a0z + (a1z - a0z) * s;
153
+ const pbx = b0x + (b1x - b0x) * t;
154
+ const pby = b0y + (b1y - b0y) * t;
155
+ const pbz = b0z + (b1z - b0z) * t;
156
+
157
+ const dx = pax - pbx;
158
+ const dy = pay - pby;
159
+ const dz = paz - pbz;
160
+ const dist_sqr = dx * dx + dy * dy + dz * dz;
161
+ const sum = a_radius + b_radius;
162
+ if (dist_sqr >= sum * sum) return false;
163
+
164
+ const dist = Math.sqrt(dist_sqr);
165
+ let nx, ny, nz;
166
+ if (dist > 0) {
167
+ const inv = 1 / dist;
168
+ nx = dx * inv; ny = dy * inv; nz = dz * inv;
169
+ } else {
170
+ // Segments touch — fall back to the world-frame direction from B's
171
+ // segment centre toward A's segment centre as a tie-break.
172
+ const acx = (a0x + a1x) * 0.5;
173
+ const acy = (a0y + a1y) * 0.5;
174
+ const acz = (a0z + a1z) * 0.5;
175
+ const bcx = (b0x + b1x) * 0.5;
176
+ const bcy = (b0y + b1y) * 0.5;
177
+ const bcz = (b0z + b1z) * 0.5;
178
+ const ddx = acx - bcx, ddy = acy - bcy, ddz = acz - bcz;
179
+ const dd_sqr = ddx * ddx + ddy * ddy + ddz * ddz;
180
+ if (dd_sqr > 0) {
181
+ const inv2 = 1 / Math.sqrt(dd_sqr);
182
+ nx = ddx * inv2; ny = ddy * inv2; nz = ddz * inv2;
183
+ } else {
184
+ nx = 1; ny = 0; nz = 0;
185
+ }
186
+ }
187
+
188
+ out[0] = nx; out[1] = ny; out[2] = nz;
189
+ out[3] = sum - dist;
190
+ out[4] = pax - nx * a_radius;
191
+ out[5] = pay - ny * a_radius;
192
+ out[6] = paz - nz * a_radius;
193
+ out[7] = pbx + nx * b_radius;
194
+ out[8] = pby + ny * b_radius;
195
+ out[9] = pbz + nz * b_radius;
196
+ return true;
197
+ }
198
+
199
+ // --- capsule vs oriented box ------------------------------------------------
200
+
201
+ const scratch_a0_local = new Float64Array(3);
202
+ const scratch_a1_local = new Float64Array(3);
203
+
204
+ /**
205
+ * Capsule (A) vs oriented box (B). Brings the capsule segment into box-local
206
+ * space, then refines via 2 fixed-point iterations between:
207
+ * - closest point on the segment to the current box-side candidate
208
+ * - clamped point on the box closest to the current segment-side candidate
209
+ *
210
+ * Two iterations suffice for the cases this engine targets (sphere-like cap
211
+ * geometry against axis-aligned-in-local box). When the segment passes
212
+ * through the box, the "inside" branch picks the smallest-overlap face
213
+ * deterministically, mirroring {@link sphere_box_contact}.
214
+ *
215
+ * @param {number[]|Float64Array} out length >= 10
216
+ * @returns {boolean}
217
+ */
218
+ export function capsule_box_contact(
219
+ out,
220
+ a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
221
+ b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_hx, b_hy, b_hz
222
+ ) {
223
+ // Bring the capsule's segment endpoints into box-local space.
224
+ v3_quat3_apply_inverse(scratch_a0_local, 0, -0, -a_half_h, 0, a_qx, a_qy, a_qz, a_qw);
225
+ // Note: we constructed the segment ends in body frame as (0, ±h, 0). We
226
+ // need them in world first, then box-local. Build world here directly
227
+ // for clarity.
228
+ capsule_world_segment(scratch_seg, a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_half_h);
229
+ // World → box-local: subtract box centre, then rotate by conjugate of box quat.
230
+ const w_a0x = scratch_seg[0] - b_cx, w_a0y = scratch_seg[1] - b_cy, w_a0z = scratch_seg[2] - b_cz;
231
+ const w_a1x = scratch_seg[3] - b_cx, w_a1y = scratch_seg[4] - b_cy, w_a1z = scratch_seg[5] - b_cz;
232
+ v3_quat3_apply_inverse(scratch_a0_local, 0, w_a0x, w_a0y, w_a0z, b_qx, b_qy, b_qz, b_qw);
233
+ v3_quat3_apply_inverse(scratch_a1_local, 0, w_a1x, w_a1y, w_a1z, b_qx, b_qy, b_qz, b_qw);
234
+
235
+ const a0lx = scratch_a0_local[0], a0ly = scratch_a0_local[1], a0lz = scratch_a0_local[2];
236
+ const a1lx = scratch_a1_local[0], a1ly = scratch_a1_local[1], a1lz = scratch_a1_local[2];
237
+
238
+ // Fixed-point iteration: start with t at the closest point to the box centre.
239
+ let t = line3_compute_segment_nearest_point_to_point_t(a0lx, a0ly, a0lz, a1lx, a1ly, a1lz, 0, 0, 0);
240
+ let plx = a0lx + (a1lx - a0lx) * t;
241
+ let ply = a0ly + (a1ly - a0ly) * t;
242
+ let plz = a0lz + (a1lz - a0lz) * t;
243
+
244
+ for (let iter = 0; iter < 2; iter++) {
245
+ // Clamp current segment point to the box → closest box-surface point.
246
+ const qlx = plx < -b_hx ? -b_hx : (plx > b_hx ? b_hx : plx);
247
+ const qly = ply < -b_hy ? -b_hy : (ply > b_hy ? b_hy : ply);
248
+ const qlz = plz < -b_hz ? -b_hz : (plz > b_hz ? b_hz : plz);
249
+
250
+ // Re-find closest segment point to that box point.
251
+ t = line3_compute_segment_nearest_point_to_point_t(
252
+ a0lx, a0ly, a0lz, a1lx, a1ly, a1lz,
253
+ qlx, qly, qlz
254
+ );
255
+ plx = a0lx + (a1lx - a0lx) * t;
256
+ ply = a0ly + (a1ly - a0ly) * t;
257
+ plz = a0lz + (a1lz - a0lz) * t;
258
+ }
259
+
260
+ // Final box-side point.
261
+ const qlx = plx < -b_hx ? -b_hx : (plx > b_hx ? b_hx : plx);
262
+ const qly = ply < -b_hy ? -b_hy : (ply > b_hy ? b_hy : ply);
263
+ const qlz = plz < -b_hz ? -b_hz : (plz > b_hz ? b_hz : plz);
264
+ const inside = qlx === plx && qly === ply && qlz === plz;
265
+
266
+ let nlx, nly, nlz, dist;
267
+ if (!inside) {
268
+ const ex = plx - qlx, ey = ply - qly, ez = plz - qlz;
269
+ const d_sqr = ex * ex + ey * ey + ez * ez;
270
+ if (d_sqr >= a_radius * a_radius) return false;
271
+ dist = Math.sqrt(d_sqr);
272
+ if (dist > 0) {
273
+ const inv = 1 / dist;
274
+ nlx = ex * inv; nly = ey * inv; nlz = ez * inv;
275
+ } else {
276
+ nlx = 1; nly = 0; nlz = 0;
277
+ }
278
+ } else {
279
+ // Segment point is inside the box. Pick smallest-overlap face.
280
+ const dxf = b_hx - Math.abs(plx);
281
+ const dyf = b_hy - Math.abs(ply);
282
+ const dzf = b_hz - Math.abs(plz);
283
+ if (dxf <= dyf && dxf <= dzf) {
284
+ nlx = plx >= 0 ? 1 : -1; nly = 0; nlz = 0; dist = -dxf;
285
+ } else if (dyf <= dzf) {
286
+ nlx = 0; nly = ply >= 0 ? 1 : -1; nlz = 0; dist = -dyf;
287
+ } else {
288
+ nlx = 0; nly = 0; nlz = plz >= 0 ? 1 : -1; dist = -dzf;
289
+ }
290
+ }
291
+
292
+ // Normal (box → capsule axis point) into world.
293
+ v3_quat3_apply(out, 0, nlx, nly, nlz, b_qx, b_qy, b_qz, b_qw);
294
+ const nx = out[0], ny = out[1], nz = out[2];
295
+ out[3] = a_radius - dist;
296
+
297
+ // Capsule-side contact: world segment point pushed back by radius.
298
+ v3_quat3_apply(out, 4, plx, ply, plz, b_qx, b_qy, b_qz, b_qw);
299
+ out[4] += b_cx - nx * a_radius;
300
+ out[5] += b_cy - ny * a_radius;
301
+ out[6] += b_cz - nz * a_radius;
302
+
303
+ // Box-side contact: world projection of the box-surface point.
304
+ v3_quat3_apply(out, 7, qlx, qly, qlz, b_qx, b_qy, b_qz, b_qw);
305
+ out[7] += b_cx;
306
+ out[8] += b_cy;
307
+ out[9] += b_cz;
308
+
309
+ return true;
310
+ }
311
+
312
+ // --- capsule vs oriented box, multi-point manifold --------------------------
313
+
314
+ /**
315
+ * Output stride per contact in {@link capsule_box_multi_contacts}.
316
+ * Matches the candidate-buffer layout used by `narrowphase_step`.
317
+ *
318
+ * 0..2 : world contact on capsule side
319
+ * 3..5 : world contact on box side
320
+ * 6..8 : normal from box (B) toward capsule (A)
321
+ * 9 : depth (positive = penetration)
322
+ *
323
+ * @type {number}
324
+ */
325
+ export const CAPSULE_BOX_CONTACT_STRIDE = 10;
326
+
327
+ /**
328
+ * Maximum contact points {@link capsule_box_multi_contacts} can emit.
329
+ * - 1 from the closest-point-on-segment vs OBB query (primary)
330
+ * - up to 2 from the cap-centre sphere-vs-OBB queries (one per endpoint)
331
+ * @type {number}
332
+ */
333
+ export const CAPSULE_BOX_MAX_CONTACTS = 3;
334
+
335
+ const scratch_primary = new Float64Array(10);
336
+ const scratch_endpoint = new Float64Array(10);
337
+
338
+ /**
339
+ * Two world positions are treated as the same contact when their squared
340
+ * distance is below this threshold. Picked so that a capsule resting flat
341
+ * doesn't double up the primary closest-segment-point contact with whichever
342
+ * endpoint it happens to coincide with.
343
+ *
344
+ * Looser than the manifold's warm-start match tolerance (≈0.02) because we
345
+ * specifically want to dedupe contacts at the *same* point; small lateral
346
+ * shifts of the capsule produce distinct contacts that should both be kept.
347
+ * @type {number}
348
+ */
349
+ const DEDUPE_DIST_SQR = 1e-6;
350
+
351
+ /**
352
+ * Multi-point capsule-vs-OBB contact generation. Emits up to
353
+ * {@link CAPSULE_BOX_MAX_CONTACTS} contacts into `out` in the
354
+ * `(wax, way, waz, wbx, wby, wbz, nx, ny, nz, depth)` stride layout.
355
+ *
356
+ * The motivation: a capsule lying flat on a face needs more than one
357
+ * contact to rest stably — a single contact at the segment's closest point
358
+ * is positionally ambiguous (every interior segment point is equidistant
359
+ * from the face), and the body wobbles around whichever point the
360
+ * iterative closest-point solver happened to converge on. Two contacts at
361
+ * the cap centres pin the capsule's rotation about its long axis.
362
+ *
363
+ * Algorithm:
364
+ * 1. Closest-point-on-segment vs OBB → primary contact (same as
365
+ * {@link capsule_box_contact}).
366
+ * 2. Treat each cap centre as a sphere of cap-radius and run
367
+ * {@link sphere_box_contact} → up to two additional contacts.
368
+ * 3. Dedupe spatially against the primary so a capsule touching with one
369
+ * cap doesn't emit two contacts at the same point.
370
+ *
371
+ * @param {Float64Array} out length >= CAPSULE_BOX_MAX_CONTACTS * CAPSULE_BOX_CONTACT_STRIDE
372
+ * @param {number} a_cx capsule centre x
373
+ * @param {number} a_cy
374
+ * @param {number} a_cz
375
+ * @param {number} a_qx capsule rotation
376
+ * @param {number} a_qy
377
+ * @param {number} a_qz
378
+ * @param {number} a_qw
379
+ * @param {number} a_radius
380
+ * @param {number} a_half_h
381
+ * @param {number} b_cx box centre x
382
+ * @param {number} b_cy
383
+ * @param {number} b_cz
384
+ * @param {number} b_qx
385
+ * @param {number} b_qy
386
+ * @param {number} b_qz
387
+ * @param {number} b_qw
388
+ * @param {number} b_hx
389
+ * @param {number} b_hy
390
+ * @param {number} b_hz
391
+ * @returns {number} number of contacts emitted, in `[0, CAPSULE_BOX_MAX_CONTACTS]`
392
+ */
393
+ export function capsule_box_multi_contacts(
394
+ out,
395
+ a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
396
+ b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_hx, b_hy, b_hz
397
+ ) {
398
+ // 1. Primary contact: closest segment point vs OBB.
399
+ const primary_ok = capsule_box_contact(
400
+ scratch_primary,
401
+ a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_radius, a_half_h,
402
+ b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw, b_hx, b_hy, b_hz
403
+ );
404
+ if (!primary_ok) return 0;
405
+
406
+ // Repack scratch_primary (normal, depth, A, B) into the candidate stride
407
+ // (A, B, normal, depth) at out[0..10).
408
+ const p_nx = scratch_primary[0], p_ny = scratch_primary[1], p_nz = scratch_primary[2];
409
+ const p_depth = scratch_primary[3];
410
+ const p_ax = scratch_primary[4], p_ay = scratch_primary[5], p_az = scratch_primary[6];
411
+ const p_bx = scratch_primary[7], p_by = scratch_primary[8], p_bz = scratch_primary[9];
412
+ out[0] = p_ax; out[1] = p_ay; out[2] = p_az;
413
+ out[3] = p_bx; out[4] = p_by; out[5] = p_bz;
414
+ out[6] = p_nx; out[7] = p_ny; out[8] = p_nz;
415
+ out[9] = p_depth;
416
+ let count = 1;
417
+
418
+ // 2. Endpoint contacts: treat each cap centre as a sphere of cap-radius.
419
+ capsule_world_segment(scratch_seg, a_cx, a_cy, a_cz, a_qx, a_qy, a_qz, a_qw, a_half_h);
420
+ const ep_x = [scratch_seg[0], scratch_seg[3]];
421
+ const ep_y = [scratch_seg[1], scratch_seg[4]];
422
+ const ep_z = [scratch_seg[2], scratch_seg[5]];
423
+
424
+ for (let i = 0; i < 2; i++) {
425
+ const ok = sphere_box_contact(
426
+ scratch_endpoint,
427
+ ep_x[i], ep_y[i], ep_z[i], a_radius,
428
+ b_cx, b_cy, b_cz, b_qx, b_qy, b_qz, b_qw,
429
+ b_hx, b_hy, b_hz
430
+ );
431
+ if (!ok) continue;
432
+
433
+ const e_nx = scratch_endpoint[0], e_ny = scratch_endpoint[1], e_nz = scratch_endpoint[2];
434
+ const e_depth = scratch_endpoint[3];
435
+ const e_ax = scratch_endpoint[4], e_ay = scratch_endpoint[5], e_az = scratch_endpoint[6];
436
+ const e_bx = scratch_endpoint[7], e_by = scratch_endpoint[8], e_bz = scratch_endpoint[9];
437
+
438
+ // Dedupe against every already-emitted contact (primary, then any
439
+ // prior endpoint we've already accepted). The capsule-side world
440
+ // point uniquely identifies a contact for this purpose — two distinct
441
+ // box-surface points always have distinct capsule-side projections
442
+ // along the local-A axis.
443
+ let duplicate = false;
444
+ for (let k = 0; k < count; k++) {
445
+ const ko = k * CAPSULE_BOX_CONTACT_STRIDE;
446
+ const dx = e_ax - out[ko];
447
+ const dy = e_ay - out[ko + 1];
448
+ const dz = e_az - out[ko + 2];
449
+ if (dx * dx + dy * dy + dz * dz < DEDUPE_DIST_SQR) { duplicate = true; break; }
450
+ }
451
+ if (duplicate) continue;
452
+
453
+ const o = count * CAPSULE_BOX_CONTACT_STRIDE;
454
+ out[o] = e_ax; out[o + 1] = e_ay; out[o + 2] = e_az;
455
+ out[o + 3] = e_bx; out[o + 4] = e_by; out[o + 5] = e_bz;
456
+ out[o + 6] = e_nx; out[o + 7] = e_ny; out[o + 8] = e_nz;
457
+ out[o + 9] = e_depth;
458
+ count++;
459
+ }
460
+
461
+ return count;
462
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @param {number[]|Float64Array} out length >= CAPSULE_TRIANGLE_MAX_CONTACTS *
3
+ * CAPSULE_TRIANGLE_CONTACT_STRIDE
4
+ * @param {number} c_cx capsule centre x
5
+ * @param {number} c_cy
6
+ * @param {number} c_cz
7
+ * @param {number} c_qx capsule rotation
8
+ * @param {number} c_qy
9
+ * @param {number} c_qz
10
+ * @param {number} c_qw
11
+ * @param {number} c_radius
12
+ * @param {number} c_half_h capsule half-height (not including caps)
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 {number} number of contacts emitted, in `[0, CAPSULE_TRIANGLE_MAX_CONTACTS]`
23
+ */
24
+ export function capsule_triangle_contact(out: number[] | Float64Array, c_cx: number, c_cy: number, c_cz: number, c_qx: number, c_qy: number, c_qz: number, c_qw: number, c_radius: number, c_half_h: number, ax: number, ay: number, az: number, bx: number, by: number, bz: number, cx: number, cy: number, cz: number): number;
25
+ /**
26
+ * Multi-point capsule-vs-triangle contact generation.
27
+ *
28
+ * A capsule is the Minkowski sum of a line segment and a sphere of
29
+ * radius `r`, so capsule-vs-triangle reduces to:
30
+ *
31
+ * 1. Find the closest pair of points between the capsule's central
32
+ * segment and the triangle (segment ↔ triangle distance).
33
+ * 2. If distance ≥ radius, no overlap.
34
+ * 3. Otherwise emit a primary contact at the segment-triangle
35
+ * closest pair, then additionally treat each cap centre (segment
36
+ * endpoint) as a sphere of cap-radius and run
37
+ * {@link sphere_triangle_contact} to produce up to 2 endpoint
38
+ * contacts. Spatial dedup against the primary so a capsule
39
+ * touching with one cap doesn't emit two contacts at the same
40
+ * point.
41
+ *
42
+ * The multi-point manifold (1 primary + 2 endpoints) is what allows a
43
+ * capsule resting flat on a triangle face to be stable — a single
44
+ * contact at the segment's closest point is positionally ambiguous
45
+ * (every interior segment point is equidistant from the face), and
46
+ * the body wobbles around whichever point the iterative closest-point
47
+ * solver happened to converge on. The endpoint contacts pin the
48
+ * capsule's rotation about its long axis.
49
+ *
50
+ * Output layout per contact (matches
51
+ * {@link CAPSULE_BOX_CONTACT_STRIDE} so the same downstream wiring
52
+ * works):
53
+ * 0..2 : world contact on capsule side
54
+ * 3..5 : world contact on triangle side
55
+ * 6..8 : normal from triangle (B) toward capsule (A)
56
+ * 9 : depth (positive = penetration)
57
+ *
58
+ * @author Alex Goldring
59
+ * @copyright Company Named Limited (c) 2026
60
+ */
61
+ /**
62
+ * Output stride per contact.
63
+ * @type {number}
64
+ */
65
+ export const CAPSULE_TRIANGLE_CONTACT_STRIDE: number;
66
+ /**
67
+ * Maximum contacts emitted: 1 primary + 2 endpoint sphere contacts.
68
+ * @type {number}
69
+ */
70
+ export const CAPSULE_TRIANGLE_MAX_CONTACTS: number;
71
+ //# sourceMappingURL=capsule_triangle_contact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capsule_triangle_contact.d.ts","sourceRoot":"","sources":["../../../../../src/engine/physics/narrowphase/capsule_triangle_contact.js"],"names":[],"mappings":"AAgPA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,8CAtBW,MAAM,EAAE,GAAC,YAAY,QAErB,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,QACN,MAAM,YACN,MAAM,YACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,MAAM,CAqElB;AArUD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH;;;GAGG;AACH,8CAFU,MAAM,CAEkC;AAElD;;;GAGG;AACH,4CAFU,MAAM,CAE+B"}