@woosh/meep-engine 2.138.19 → 2.139.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 (496) hide show
  1. package/package.json +2 -1
  2. package/src/core/collection/PairUint32Map.d.ts +100 -0
  3. package/src/core/collection/PairUint32Map.d.ts.map +1 -0
  4. package/src/core/collection/PairUint32Map.js +321 -0
  5. package/src/core/collection/Uint32Map.d.ts +119 -0
  6. package/src/core/collection/Uint32Map.d.ts.map +1 -0
  7. package/src/core/collection/Uint32Map.js +345 -0
  8. package/src/core/collection/array/array_shuffle.d.ts +10 -3
  9. package/src/core/collection/array/array_shuffle.d.ts.map +1 -1
  10. package/src/core/collection/array/array_shuffle.js +27 -22
  11. package/src/core/collection/heap/FibonacciHeap.d.ts +195 -0
  12. package/src/core/collection/heap/FibonacciHeap.d.ts.map +1 -0
  13. package/src/core/collection/heap/FibonacciHeap.js +586 -0
  14. package/src/core/collection/heap/Uint32Heap.js +1 -1
  15. package/src/core/collection/heap/Uint32Heap4.d.ts +169 -0
  16. package/src/core/collection/heap/Uint32Heap4.d.ts.map +1 -0
  17. package/src/core/collection/heap/Uint32Heap4.js +490 -0
  18. package/src/core/geom/3d/line/line3_closest_points_segment_segment.d.ts +27 -0
  19. package/src/core/geom/3d/line/line3_closest_points_segment_segment.d.ts.map +1 -0
  20. package/src/core/geom/3d/line/line3_closest_points_segment_segment.js +88 -0
  21. package/src/core/geom/3d/shape/BoxShape3D.d.ts +61 -0
  22. package/src/core/geom/3d/shape/BoxShape3D.d.ts.map +1 -0
  23. package/src/core/geom/3d/shape/BoxShape3D.js +158 -0
  24. package/src/core/geom/3d/shape/CapsuleShape3D.d.ts +11 -0
  25. package/src/core/geom/3d/shape/CapsuleShape3D.d.ts.map +1 -1
  26. package/src/core/geom/3d/shape/CapsuleShape3D.js +12 -0
  27. package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts +37 -9
  28. package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts.map +1 -1
  29. package/src/core/geom/3d/shape/UnitCubeShape3D.js +45 -98
  30. package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts +10 -0
  31. package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts.map +1 -1
  32. package/src/core/geom/3d/shape/UnitSphereShape3D.js +11 -0
  33. package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.d.ts +61 -0
  34. package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.d.ts.map +1 -0
  35. package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.js +148 -0
  36. package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.d.ts +39 -0
  37. package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.d.ts.map +1 -0
  38. package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.js +147 -0
  39. package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.d.ts +15 -0
  40. package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.d.ts.map +1 -0
  41. package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.js +22 -0
  42. package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.d.ts +2 -0
  43. package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.d.ts.map +1 -0
  44. package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.js +673 -0
  45. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.d.ts +26 -0
  46. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.d.ts.map +1 -0
  47. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.js +222 -0
  48. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.d.ts +34 -0
  49. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.d.ts.map +1 -0
  50. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.js +146 -0
  51. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.d.ts +36 -0
  52. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.d.ts.map +1 -0
  53. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.js +232 -0
  54. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.d.ts +33 -0
  55. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.d.ts.map +1 -0
  56. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.js +255 -0
  57. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.d.ts +68 -0
  58. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.d.ts.map +1 -0
  59. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.js +365 -0
  60. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.d.ts +31 -0
  61. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.d.ts.map +1 -0
  62. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.js +112 -0
  63. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.d.ts +22 -0
  64. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.d.ts.map +1 -0
  65. package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.js +55 -0
  66. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.d.ts +32 -0
  67. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.d.ts.map +1 -0
  68. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.js +66 -0
  69. package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts +22 -0
  70. package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts.map +1 -1
  71. package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.js +49 -0
  72. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.d.ts +134 -0
  73. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.d.ts.map +1 -1
  74. package/src/core/geom/3d/topology/struct/binary/BinaryTopology.js +276 -3
  75. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts +17 -0
  76. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts.map +1 -0
  77. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.js +135 -0
  78. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.d.ts +14 -0
  79. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.d.ts.map +1 -0
  80. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.js +177 -0
  81. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.d.ts.map +1 -1
  82. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.js +20 -4
  83. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.d.ts.map +1 -1
  84. package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.js +5 -3
  85. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_create.d.ts.map +1 -1
  86. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_create.js +9 -0
  87. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_get_or_create.d.ts.map +1 -1
  88. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_get_or_create.js +21 -45
  89. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill.d.ts.map +1 -1
  90. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill.js +7 -1
  91. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts +8 -6
  92. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts.map +1 -1
  93. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.js +8 -6
  94. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.d.ts +22 -0
  95. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.d.ts.map +1 -0
  96. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.js +73 -0
  97. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.d.ts.map +1 -1
  98. package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.js +51 -1
  99. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.d.ts +10 -0
  100. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.d.ts.map +1 -0
  101. package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.js +42 -0
  102. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.d.ts +28 -0
  103. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.d.ts.map +1 -0
  104. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.js +227 -0
  105. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.d.ts +13 -0
  106. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.d.ts.map +1 -0
  107. package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.js +108 -0
  108. package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.d.ts +11 -0
  109. package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.d.ts.map +1 -0
  110. package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.js +20 -0
  111. package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.d.ts +20 -0
  112. package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.d.ts.map +1 -0
  113. package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.js +38 -0
  114. package/src/core/graph/csr/CSRGraph.d.ts +168 -0
  115. package/src/core/graph/csr/CSRGraph.d.ts.map +1 -0
  116. package/src/core/graph/csr/CSRGraph.js +319 -0
  117. package/src/core/graph/metis/cluster_mesh_metis.d.ts +12 -0
  118. package/src/core/graph/metis/cluster_mesh_metis.d.ts.map +1 -1
  119. package/src/core/graph/metis/cluster_mesh_metis.js +12 -0
  120. package/src/core/graph/metis/metis.d.ts +19 -0
  121. package/src/core/graph/metis/metis.d.ts.map +1 -1
  122. package/src/core/graph/metis/metis.js +20 -0
  123. package/src/core/graph/metis/metis_cluster_bs.d.ts +11 -0
  124. package/src/core/graph/metis/metis_cluster_bs.d.ts.map +1 -1
  125. package/src/core/graph/metis/metis_cluster_bs.js +11 -0
  126. package/src/core/graph/metis/metis_options.d.ts +17 -2
  127. package/src/core/graph/metis/metis_options.d.ts.map +1 -1
  128. package/src/core/graph/metis/metis_options.js +17 -2
  129. package/src/core/graph/metis/native/MetisGraph.d.ts +144 -0
  130. package/src/core/graph/metis/native/MetisGraph.d.ts.map +1 -0
  131. package/src/core/graph/metis/native/MetisGraph.js +212 -0
  132. package/src/core/graph/metis/native/bisection/BisectionScratch.d.ts +72 -0
  133. package/src/core/graph/metis/native/bisection/BisectionScratch.d.ts.map +1 -0
  134. package/src/core/graph/metis/native/bisection/BisectionScratch.js +101 -0
  135. package/src/core/graph/metis/native/bisection/bisect_graph.d.ts +37 -0
  136. package/src/core/graph/metis/native/bisection/bisect_graph.d.ts.map +1 -0
  137. package/src/core/graph/metis/native/bisection/bisect_graph.js +100 -0
  138. package/src/core/graph/metis/native/bisection/compute_2way_params.d.ts +15 -0
  139. package/src/core/graph/metis/native/bisection/compute_2way_params.d.ts.map +1 -0
  140. package/src/core/graph/metis/native/bisection/compute_2way_params.js +84 -0
  141. package/src/core/graph/metis/native/bisection/fm_2way.d.ts +30 -0
  142. package/src/core/graph/metis/native/bisection/fm_2way.d.ts.map +1 -0
  143. package/src/core/graph/metis/native/bisection/fm_2way.js +290 -0
  144. package/src/core/graph/metis/native/bisection/grow_bisection.d.ts +23 -0
  145. package/src/core/graph/metis/native/bisection/grow_bisection.d.ts.map +1 -0
  146. package/src/core/graph/metis/native/bisection/grow_bisection.js +137 -0
  147. package/src/core/graph/metis/native/bisection/split_graph_two_way.d.ts +28 -0
  148. package/src/core/graph/metis/native/bisection/split_graph_two_way.d.ts.map +1 -0
  149. package/src/core/graph/metis/native/bisection/split_graph_two_way.js +119 -0
  150. package/src/core/graph/metis/native/coarsen/coarsen_graph.d.ts +20 -0
  151. package/src/core/graph/metis/native/coarsen/coarsen_graph.d.ts.map +1 -0
  152. package/src/core/graph/metis/native/coarsen/coarsen_graph.js +94 -0
  153. package/src/core/graph/metis/native/coarsen/create_coarse_graph.d.ts +24 -0
  154. package/src/core/graph/metis/native/coarsen/create_coarse_graph.d.ts.map +1 -0
  155. package/src/core/graph/metis/native/coarsen/create_coarse_graph.js +158 -0
  156. package/src/core/graph/metis/native/coarsen/match_shem.d.ts +41 -0
  157. package/src/core/graph/metis/native/coarsen/match_shem.d.ts.map +1 -0
  158. package/src/core/graph/metis/native/coarsen/match_shem.js +175 -0
  159. package/src/core/graph/metis/native/initial/initial_kway_bfs.d.ts +24 -0
  160. package/src/core/graph/metis/native/initial/initial_kway_bfs.d.ts.map +1 -0
  161. package/src/core/graph/metis/native/initial/initial_kway_bfs.js +122 -0
  162. package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.d.ts +29 -0
  163. package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.d.ts.map +1 -0
  164. package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.js +170 -0
  165. package/src/core/graph/metis/native/metis_partition_kway.d.ts +41 -0
  166. package/src/core/graph/metis/native/metis_partition_kway.d.ts.map +1 -0
  167. package/src/core/graph/metis/native/metis_partition_kway.js +126 -0
  168. package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.d.ts +62 -0
  169. package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.d.ts.map +1 -0
  170. package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.js +261 -0
  171. package/src/core/graph/metis/native/refine/RefinementScratch.d.ts +45 -0
  172. package/src/core/graph/metis/native/refine/RefinementScratch.d.ts.map +1 -0
  173. package/src/core/graph/metis/native/refine/RefinementScratch.js +53 -0
  174. package/src/core/graph/metis/native/refine/compute_kway_params.d.ts +18 -0
  175. package/src/core/graph/metis/native/refine/compute_kway_params.d.ts.map +1 -0
  176. package/src/core/graph/metis/native/refine/compute_kway_params.js +138 -0
  177. package/src/core/graph/metis/native/refine/fm_kway.d.ts +63 -0
  178. package/src/core/graph/metis/native/refine/fm_kway.d.ts.map +1 -0
  179. package/src/core/graph/metis/native/refine/fm_kway.js +462 -0
  180. package/src/core/graph/metis/native/refine/project_kway.d.ts +22 -0
  181. package/src/core/graph/metis/native/refine/project_kway.d.ts.map +1 -0
  182. package/src/core/graph/metis/native/refine/project_kway.js +43 -0
  183. package/src/core/graph/metis/native/refine/refine_kway.d.ts +34 -0
  184. package/src/core/graph/metis/native/refine/refine_kway.d.ts.map +1 -0
  185. package/src/core/graph/metis/native/refine/refine_kway.js +43 -0
  186. package/src/core/math/linalg/eigen/matrix_householder_in_place.d.ts +2 -2
  187. package/src/core/math/linalg/eigen/matrix_householder_in_place.js +2 -2
  188. package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts +6 -4
  189. package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts.map +1 -1
  190. package/src/core/math/linalg/eigen/matrix_qr_in_place.js +69 -23
  191. package/src/engine/EngineHarness.d.ts +3 -1
  192. package/src/engine/EngineHarness.d.ts.map +1 -1
  193. package/src/engine/EngineHarness.js +6 -4
  194. package/src/engine/control/first-person/DESIGN.md +30 -6
  195. package/src/engine/control/first-person/DESIGN_EXTENSIONS.md +563 -0
  196. package/src/engine/control/first-person/FirstPersonPlayerController.d.ts +102 -9
  197. package/src/engine/control/first-person/FirstPersonPlayerController.d.ts.map +1 -1
  198. package/src/engine/control/first-person/FirstPersonPlayerController.js +38 -3
  199. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts +533 -4
  200. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts.map +1 -1
  201. package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.js +315 -6
  202. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts +220 -22
  203. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -1
  204. package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +858 -241
  205. package/src/engine/control/first-person/TODO.md +127 -0
  206. package/src/engine/control/first-person/abilities/Ability.d.ts +101 -0
  207. package/src/engine/control/first-person/abilities/Ability.d.ts.map +1 -0
  208. package/src/engine/control/first-person/abilities/Ability.js +119 -0
  209. package/src/engine/control/first-person/abilities/AbilitySet.d.ts +86 -0
  210. package/src/engine/control/first-person/abilities/AbilitySet.d.ts.map +1 -0
  211. package/src/engine/control/first-person/abilities/AbilitySet.js +185 -0
  212. package/src/engine/control/first-person/abilities/LedgeGrab.d.ts +62 -0
  213. package/src/engine/control/first-person/abilities/LedgeGrab.d.ts.map +1 -0
  214. package/src/engine/control/first-person/abilities/LedgeGrab.js +199 -0
  215. package/src/engine/control/first-person/abilities/Mantle.d.ts +45 -0
  216. package/src/engine/control/first-person/abilities/Mantle.d.ts.map +1 -0
  217. package/src/engine/control/first-person/abilities/Mantle.js +188 -0
  218. package/src/engine/control/first-person/abilities/Slide.d.ts +33 -0
  219. package/src/engine/control/first-person/abilities/Slide.d.ts.map +1 -0
  220. package/src/engine/control/first-person/abilities/Slide.js +158 -0
  221. package/src/engine/control/first-person/abilities/WallJump.d.ts +45 -0
  222. package/src/engine/control/first-person/abilities/WallJump.d.ts.map +1 -0
  223. package/src/engine/control/first-person/abilities/WallJump.js +131 -0
  224. package/src/engine/control/first-person/abilities/WallRun.d.ts +44 -0
  225. package/src/engine/control/first-person/abilities/WallRun.d.ts.map +1 -0
  226. package/src/engine/control/first-person/abilities/WallRun.js +180 -0
  227. package/src/engine/control/first-person/composer/EyeOffsetStack.d.ts +49 -0
  228. package/src/engine/control/first-person/composer/EyeOffsetStack.d.ts.map +1 -0
  229. package/src/engine/control/first-person/composer/EyeOffsetStack.js +60 -0
  230. package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.d.ts +100 -0
  231. package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.d.ts.map +1 -0
  232. package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.js +133 -0
  233. package/src/engine/control/first-person/mastery/DecisionPoint.d.ts +10 -0
  234. package/src/engine/control/first-person/mastery/DecisionPoint.d.ts.map +1 -0
  235. package/src/engine/control/first-person/mastery/DecisionPoint.js +30 -0
  236. package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.d.ts +61 -0
  237. package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.d.ts.map +1 -0
  238. package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.js +109 -0
  239. package/src/engine/control/first-person/mastery/MasteryEvaluator.d.ts +40 -0
  240. package/src/engine/control/first-person/mastery/MasteryEvaluator.d.ts.map +1 -0
  241. package/src/engine/control/first-person/mastery/MasteryEvaluator.js +45 -0
  242. package/src/engine/control/first-person/mastery/MasteryScore.d.ts +68 -0
  243. package/src/engine/control/first-person/mastery/MasteryScore.d.ts.map +1 -0
  244. package/src/engine/control/first-person/mastery/MasteryScore.js +100 -0
  245. package/src/engine/control/first-person/mastery/MasterySet.d.ts +60 -0
  246. package/src/engine/control/first-person/mastery/MasterySet.d.ts.map +1 -0
  247. package/src/engine/control/first-person/mastery/MasterySet.js +86 -0
  248. package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.d.ts +58 -0
  249. package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.d.ts.map +1 -0
  250. package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.js +83 -0
  251. package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.d.ts +69 -0
  252. package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.d.ts.map +1 -0
  253. package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.js +109 -0
  254. package/src/engine/control/first-person/math/Spring.d.ts +56 -0
  255. package/src/engine/control/first-person/math/Spring.d.ts.map +1 -0
  256. package/src/engine/control/first-person/math/Spring.js +71 -0
  257. package/src/engine/control/first-person/math/computeLRCBreathRate.d.ts +26 -0
  258. package/src/engine/control/first-person/math/computeLRCBreathRate.d.ts.map +1 -0
  259. package/src/engine/control/first-person/math/computeLRCBreathRate.js +41 -0
  260. package/src/engine/control/first-person/math/computeMassRatios.d.ts +35 -0
  261. package/src/engine/control/first-person/math/computeMassRatios.d.ts.map +1 -0
  262. package/src/engine/control/first-person/math/computeMassRatios.js +44 -0
  263. package/src/engine/control/first-person/pose/FirstPersonPose.d.ts +31 -1
  264. package/src/engine/control/first-person/pose/FirstPersonPose.d.ts.map +1 -1
  265. package/src/engine/control/first-person/pose/FirstPersonPose.js +49 -3
  266. package/src/engine/control/first-person/pose/FirstPersonPosture.d.ts +7 -0
  267. package/src/engine/control/first-person/pose/FirstPersonPosture.d.ts.map +1 -0
  268. package/src/engine/control/first-person/pose/FirstPersonPosture.js +27 -0
  269. package/src/engine/control/first-person/prototype_first_person_controller.js +550 -119
  270. package/src/engine/control/first-person/sensors/FirstPersonSensors.d.ts +58 -0
  271. package/src/engine/control/first-person/sensors/FirstPersonSensors.d.ts.map +1 -0
  272. package/src/engine/control/first-person/sensors/FirstPersonSensors.js +77 -0
  273. package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts +80 -0
  274. package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts.map +1 -0
  275. package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.js +196 -0
  276. package/src/engine/control/first-person/test/buildTestPlayer.d.ts +20 -0
  277. package/src/engine/control/first-person/test/buildTestPlayer.d.ts.map +1 -0
  278. package/src/engine/control/first-person/test/buildTestPlayer.js +28 -0
  279. package/src/engine/ecs/EntityManager.d.ts +2 -2
  280. package/src/engine/ecs/EntityManager.d.ts.map +1 -1
  281. package/src/engine/ecs/EntityManager.js +13 -8
  282. package/src/engine/ecs/System.d.ts.map +1 -1
  283. package/src/engine/ecs/System.js +2 -2
  284. package/src/engine/graphics/camera/testClippingPlaneComputation.js +0 -2
  285. package/src/engine/graphics/ecs/light/Light.d.ts.map +1 -1
  286. package/src/engine/graphics/ecs/light/Light.js +27 -0
  287. package/src/engine/graphics/ecs/light/LightSystem.js +1 -1
  288. package/src/engine/graphics/ecs/path/PathDisplaySystem.d.ts.map +1 -1
  289. package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
  290. package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +0 -2
  291. package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -2
  292. package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +0 -2
  293. package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +0 -2
  294. package/src/engine/navigation/grid/find_path_on_grid_astar.d.ts.map +1 -1
  295. package/src/engine/navigation/grid/find_path_on_grid_astar.js +11 -2
  296. package/src/engine/navigation/mesh/bt_mesh_face_find_path.d.ts.map +1 -1
  297. package/src/engine/navigation/mesh/bt_mesh_face_find_path.js +11 -1
  298. package/src/engine/physics/PLAN.md +236 -0
  299. package/src/engine/physics/body/BodyStorage.d.ts +187 -0
  300. package/src/engine/physics/body/BodyStorage.d.ts.map +1 -0
  301. package/src/engine/physics/body/BodyStorage.js +427 -0
  302. package/src/engine/physics/broadphase/PairList.d.ts +62 -0
  303. package/src/engine/physics/broadphase/PairList.d.ts.map +1 -0
  304. package/src/engine/physics/broadphase/PairList.js +97 -0
  305. package/src/engine/physics/broadphase/aabb_transform_oriented.d.ts +30 -0
  306. package/src/engine/physics/broadphase/aabb_transform_oriented.d.ts.map +1 -0
  307. package/src/engine/physics/broadphase/aabb_transform_oriented.js +93 -0
  308. package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts +16 -0
  309. package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts.map +1 -0
  310. package/src/engine/physics/broadphase/compute_fat_world_aabb.js +61 -0
  311. package/src/engine/physics/broadphase/generate_pairs.d.ts +38 -0
  312. package/src/engine/physics/broadphase/generate_pairs.d.ts.map +1 -0
  313. package/src/engine/physics/broadphase/generate_pairs.js +101 -0
  314. package/src/engine/physics/contact/ManifoldStore.d.ts +226 -0
  315. package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -0
  316. package/src/engine/physics/contact/ManifoldStore.js +499 -0
  317. package/src/engine/physics/ecs/BodyKind.d.ts +23 -0
  318. package/src/engine/physics/ecs/BodyKind.d.ts.map +1 -0
  319. package/src/engine/physics/ecs/BodyKind.js +24 -0
  320. package/src/engine/physics/ecs/Collider.d.ts +98 -0
  321. package/src/engine/physics/ecs/Collider.d.ts.map +1 -0
  322. package/src/engine/physics/ecs/Collider.js +136 -0
  323. package/src/engine/physics/ecs/ColliderFlags.d.ts +14 -0
  324. package/src/engine/physics/ecs/ColliderFlags.d.ts.map +1 -0
  325. package/src/engine/physics/ecs/ColliderFlags.js +15 -0
  326. package/src/engine/physics/ecs/ColliderObserverSystem.d.ts +58 -0
  327. package/src/engine/physics/ecs/ColliderObserverSystem.d.ts.map +1 -0
  328. package/src/engine/physics/ecs/ColliderObserverSystem.js +103 -0
  329. package/src/engine/physics/ecs/ColliderSerializationAdapter.d.ts +25 -0
  330. package/src/engine/physics/ecs/ColliderSerializationAdapter.d.ts.map +1 -0
  331. package/src/engine/physics/ecs/ColliderSerializationAdapter.js +37 -0
  332. package/src/engine/physics/ecs/PhysicsEvents.d.ts +15 -0
  333. package/src/engine/physics/ecs/PhysicsEvents.d.ts.map +1 -0
  334. package/src/engine/physics/ecs/PhysicsEvents.js +16 -0
  335. package/src/engine/physics/ecs/PhysicsSystem.d.ts +520 -0
  336. package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -0
  337. package/src/engine/physics/ecs/PhysicsSystem.js +1159 -0
  338. package/src/engine/physics/ecs/RigidBody.d.ts +197 -0
  339. package/src/engine/physics/ecs/RigidBody.d.ts.map +1 -0
  340. package/src/engine/physics/ecs/RigidBody.js +240 -0
  341. package/src/engine/physics/ecs/RigidBodyFlags.d.ts +21 -0
  342. package/src/engine/physics/ecs/RigidBodyFlags.d.ts.map +1 -0
  343. package/src/engine/physics/ecs/RigidBodyFlags.js +22 -0
  344. package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts +28 -0
  345. package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts.map +1 -0
  346. package/src/engine/physics/ecs/RigidBodySerializationAdapter.js +81 -0
  347. package/src/engine/physics/ecs/SleepState.d.ts +11 -0
  348. package/src/engine/physics/ecs/SleepState.d.ts.map +1 -0
  349. package/src/engine/physics/ecs/SleepState.js +12 -0
  350. package/src/engine/physics/events/ContactEventBuffer.d.ts +46 -0
  351. package/src/engine/physics/events/ContactEventBuffer.d.ts.map +1 -0
  352. package/src/engine/physics/events/ContactEventBuffer.js +83 -0
  353. package/src/engine/physics/events/diff_manifolds.d.ts +25 -0
  354. package/src/engine/physics/events/diff_manifolds.d.ts.map +1 -0
  355. package/src/engine/physics/events/diff_manifolds.js +50 -0
  356. package/src/engine/physics/fluid/FluidField.d.ts +294 -16
  357. package/src/engine/physics/fluid/FluidField.d.ts.map +1 -1
  358. package/src/engine/physics/fluid/FluidField.js +510 -66
  359. package/src/engine/physics/fluid/FluidSimulator.d.ts +188 -5
  360. package/src/engine/physics/fluid/FluidSimulator.d.ts.map +1 -1
  361. package/src/engine/physics/fluid/FluidSimulator.js +455 -95
  362. package/src/engine/physics/fluid/SliceVisualiser.d.ts +29 -6
  363. package/src/engine/physics/fluid/SliceVisualiser.d.ts.map +1 -1
  364. package/src/engine/physics/fluid/SliceVisualiser.js +190 -165
  365. package/src/engine/physics/fluid/ecs/FluidComponent.d.ts +154 -0
  366. package/src/engine/physics/fluid/ecs/FluidComponent.d.ts.map +1 -0
  367. package/src/engine/physics/fluid/ecs/FluidComponent.js +238 -0
  368. package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.d.ts +45 -0
  369. package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.d.ts.map +1 -0
  370. package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.js +89 -0
  371. package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +107 -0
  372. package/src/engine/physics/fluid/ecs/FluidSystem.d.ts.map +1 -0
  373. package/src/engine/physics/fluid/ecs/FluidSystem.js +278 -0
  374. package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts +62 -1
  375. package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts.map +1 -1
  376. package/src/engine/physics/fluid/effector/AbstractFluidEffector.js +81 -6
  377. package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts +17 -4
  378. package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts.map +1 -1
  379. package/src/engine/physics/fluid/effector/GlobalFluidEffector.js +105 -12
  380. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts +43 -0
  381. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts.map +1 -0
  382. package/src/engine/physics/fluid/effector/ImpulseFluidEffector.js +210 -0
  383. package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts +62 -1
  384. package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts.map +1 -1
  385. package/src/engine/physics/fluid/effector/WakeFluidEffector.js +302 -8
  386. package/src/engine/physics/fluid/prototype.js +102 -91
  387. package/src/engine/physics/fluid/solver/optimal_sor_omega.d.ts +33 -0
  388. package/src/engine/physics/fluid/solver/optimal_sor_omega.d.ts.map +1 -0
  389. package/src/engine/physics/fluid/solver/optimal_sor_omega.js +41 -0
  390. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.d.ts +20 -5
  391. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.d.ts.map +1 -1
  392. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.js +60 -38
  393. package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.d.ts +25 -4
  394. package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.d.ts.map +1 -1
  395. package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.js +93 -73
  396. package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.d.ts +23 -0
  397. package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.d.ts.map +1 -0
  398. package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.js +60 -0
  399. package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.d.ts +23 -0
  400. package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.d.ts.map +1 -0
  401. package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.js +68 -0
  402. package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts +30 -0
  403. package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts.map +1 -0
  404. package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.js +66 -0
  405. package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.d.ts +26 -0
  406. package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.d.ts.map +1 -0
  407. package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.js +113 -0
  408. package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.d.ts +30 -0
  409. package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.d.ts.map +1 -0
  410. package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.js +107 -0
  411. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts +49 -0
  412. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts.map +1 -0
  413. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.js +126 -0
  414. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts +93 -0
  415. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts.map +1 -0
  416. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.js +424 -0
  417. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.d.ts +20 -0
  418. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.d.ts.map +1 -0
  419. package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.js +83 -0
  420. package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts +26 -0
  421. package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts.map +1 -0
  422. package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.js +70 -0
  423. package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts.map +1 -1
  424. package/src/engine/physics/gjk/expanding_polytope_algorithm.js +8 -10
  425. package/src/engine/physics/inertia/world_inverse_inertia.d.ts +29 -0
  426. package/src/engine/physics/inertia/world_inverse_inertia.d.ts.map +1 -0
  427. package/src/engine/physics/inertia/world_inverse_inertia.js +79 -0
  428. package/src/engine/physics/integration/integrate_position.d.ts +16 -0
  429. package/src/engine/physics/integration/integrate_position.d.ts.map +1 -0
  430. package/src/engine/physics/integration/integrate_position.js +48 -0
  431. package/src/engine/physics/integration/integrate_velocity.d.ts +25 -0
  432. package/src/engine/physics/integration/integrate_velocity.d.ts.map +1 -0
  433. package/src/engine/physics/integration/integrate_velocity.js +79 -0
  434. package/src/engine/physics/integration/quat_integrate.d.ts +27 -0
  435. package/src/engine/physics/integration/quat_integrate.d.ts.map +1 -0
  436. package/src/engine/physics/integration/quat_integrate.js +62 -0
  437. package/src/engine/physics/island/IslandBuilder.d.ts +167 -0
  438. package/src/engine/physics/island/IslandBuilder.d.ts.map +1 -0
  439. package/src/engine/physics/island/IslandBuilder.js +411 -0
  440. package/src/engine/physics/island/union_find.d.ts +51 -0
  441. package/src/engine/physics/island/union_find.d.ts.map +1 -0
  442. package/src/engine/physics/island/union_find.js +76 -0
  443. package/src/engine/physics/narrowphase/PosedShape.d.ts +59 -0
  444. package/src/engine/physics/narrowphase/PosedShape.d.ts.map +1 -0
  445. package/src/engine/physics/narrowphase/PosedShape.js +110 -0
  446. package/src/engine/physics/narrowphase/box_box_manifold.d.ts +32 -0
  447. package/src/engine/physics/narrowphase/box_box_manifold.d.ts.map +1 -0
  448. package/src/engine/physics/narrowphase/box_box_manifold.js +543 -0
  449. package/src/engine/physics/narrowphase/capsule_contacts.d.ts +122 -0
  450. package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -0
  451. package/src/engine/physics/narrowphase/capsule_contacts.js +508 -0
  452. package/src/engine/physics/narrowphase/narrowphase_step.d.ts +11 -0
  453. package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -0
  454. package/src/engine/physics/narrowphase/narrowphase_step.js +382 -0
  455. package/src/engine/physics/narrowphase/sphere_box_contact.d.ts +38 -0
  456. package/src/engine/physics/narrowphase/sphere_box_contact.d.ts.map +1 -0
  457. package/src/engine/physics/narrowphase/sphere_box_contact.js +130 -0
  458. package/src/engine/physics/narrowphase/sphere_sphere_contact.d.ts +26 -0
  459. package/src/engine/physics/narrowphase/sphere_sphere_contact.d.ts.map +1 -0
  460. package/src/engine/physics/narrowphase/sphere_sphere_contact.js +51 -0
  461. package/src/engine/physics/queries/PhysicsSurfacePoint.d.ts +83 -0
  462. package/src/engine/physics/queries/PhysicsSurfacePoint.d.ts.map +1 -0
  463. package/src/engine/physics/queries/PhysicsSurfacePoint.js +100 -0
  464. package/src/engine/physics/queries/raycast.d.ts +20 -0
  465. package/src/engine/physics/queries/raycast.d.ts.map +1 -0
  466. package/src/engine/physics/queries/raycast.js +249 -0
  467. package/src/engine/physics/solver/friction_cone.d.ts +16 -0
  468. package/src/engine/physics/solver/friction_cone.d.ts.map +1 -0
  469. package/src/engine/physics/solver/friction_cone.js +37 -0
  470. package/src/engine/physics/solver/solve_contacts.d.ts +36 -0
  471. package/src/engine/physics/solver/solve_contacts.d.ts.map +1 -0
  472. package/src/engine/physics/solver/solve_contacts.js +598 -0
  473. package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.d.ts +0 -34
  474. package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.d.ts.map +0 -1
  475. package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.js +0 -66
  476. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.d.ts +0 -2
  477. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.d.ts.map +0 -1
  478. package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.js +0 -54
  479. package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.d.ts +0 -2
  480. package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.d.ts.map +0 -1
  481. package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.js +0 -26
  482. package/src/engine/ecs/components/Motion.d.ts +0 -21
  483. package/src/engine/ecs/components/Motion.d.ts.map +0 -1
  484. package/src/engine/ecs/components/Motion.js +0 -27
  485. package/src/engine/ecs/components/MotionSerializationAdapter.d.ts +0 -20
  486. package/src/engine/ecs/components/MotionSerializationAdapter.d.ts.map +0 -1
  487. package/src/engine/ecs/components/MotionSerializationAdapter.js +0 -26
  488. package/src/engine/ecs/systems/MotionSystem.d.ts +0 -9
  489. package/src/engine/ecs/systems/MotionSystem.d.ts.map +0 -1
  490. package/src/engine/ecs/systems/MotionSystem.js +0 -29
  491. package/src/engine/physics/fluid/Fluid.d.ts +0 -26
  492. package/src/engine/physics/fluid/Fluid.d.ts.map +0 -1
  493. package/src/engine/physics/fluid/Fluid.js +0 -221
  494. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.d.ts +0 -7
  495. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.d.ts.map +0 -1
  496. package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.js +0 -8
@@ -0,0 +1,88 @@
1
+ import { clamp01 } from "../../../math/clamp01.js";
2
+
3
+ /**
4
+ * Lengths-squared below this threshold are treated as "this segment is a
5
+ * point" so the algorithm degrades gracefully to point-segment closest.
6
+ * @type {number}
7
+ */
8
+ const SEGMENT_EPS = 1e-12;
9
+
10
+ /**
11
+ * Closest-point pair on two 3D line segments. Writes parameters `s` and `t`
12
+ * (each in `[0, 1]`) into `out[0]` and `out[1]` such that:
13
+ *
14
+ * closest_point_on_S1 = P1 + s * (Q1 - P1)
15
+ * closest_point_on_S2 = P2 + t * (Q2 - P2)
16
+ *
17
+ * Source: Ericson, *Real-Time Collision Detection*, §5.1.9. Robust to
18
+ * degenerate inputs (point-like segments, parallel segments) — both
19
+ * cases fall back to the clamped point-on-line projection.
20
+ *
21
+ * @param {number[]|Float64Array} out length >= 2; receives [s, t]
22
+ * @param {number} p1x segment-A start x
23
+ * @param {number} p1y
24
+ * @param {number} p1z
25
+ * @param {number} q1x segment-A end x
26
+ * @param {number} q1y
27
+ * @param {number} q1z
28
+ * @param {number} p2x segment-B start x
29
+ * @param {number} p2y
30
+ * @param {number} p2z
31
+ * @param {number} q2x segment-B end x
32
+ * @param {number} q2y
33
+ * @param {number} q2z
34
+ */
35
+ export function line3_closest_points_segment_segment(
36
+ out,
37
+ p1x, p1y, p1z, q1x, q1y, q1z,
38
+ p2x, p2y, p2z, q2x, q2y, q2z
39
+ ) {
40
+ const d1x = q1x - p1x, d1y = q1y - p1y, d1z = q1z - p1z;
41
+ const d2x = q2x - p2x, d2y = q2y - p2y, d2z = q2z - p2z;
42
+ const rx = p1x - p2x, ry = p1y - p2y, rz = p1z - p2z;
43
+
44
+ const a = d1x * d1x + d1y * d1y + d1z * d1z; // |d1|²
45
+ const e = d2x * d2x + d2y * d2y + d2z * d2z; // |d2|²
46
+ const f = d2x * rx + d2y * ry + d2z * rz; // d2·r
47
+
48
+ let s, t;
49
+
50
+ if (a <= SEGMENT_EPS && e <= SEGMENT_EPS) {
51
+ // Both degenerate to points.
52
+ s = 0; t = 0;
53
+ } else if (a <= SEGMENT_EPS) {
54
+ // S1 is a point.
55
+ s = 0;
56
+ t = clamp01(f / e);
57
+ } else {
58
+ const c = d1x * rx + d1y * ry + d1z * rz; // d1·r
59
+ if (e <= SEGMENT_EPS) {
60
+ // S2 is a point.
61
+ t = 0;
62
+ s = clamp01(-c / a);
63
+ } else {
64
+ const b = d1x * d2x + d1y * d2y + d1z * d2z; // d1·d2
65
+ const denom = a * e - b * b; // always >= 0
66
+
67
+ if (denom !== 0) {
68
+ s = clamp01((b * f - c * e) / denom);
69
+ } else {
70
+ // Segments are parallel — any s is fine; pick 0.
71
+ s = 0;
72
+ }
73
+
74
+ t = (b * s + f) / e;
75
+
76
+ if (t < 0) {
77
+ t = 0;
78
+ s = clamp01(-c / a);
79
+ } else if (t > 1) {
80
+ t = 1;
81
+ s = clamp01((b - c) / a);
82
+ }
83
+ }
84
+ }
85
+
86
+ out[0] = s;
87
+ out[1] = t;
88
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Axis-aligned box of arbitrary half-extents, expressed in the body's local
3
+ * frame. The shape spans `[-half_extents.x, +half_extents.x]` along X and
4
+ * symmetrically on Y / Z.
5
+ *
6
+ * This is the generalisation of {@link UnitCubeShape3D} (which is fixed to
7
+ * `0.5` per axis). The physics narrowphase recognises both via the shared
8
+ * `isBoxShape3D` prototype marker and reads `half_extents.x / y / z` to feed
9
+ * the closed-form sphere-box and box-box paths.
10
+ *
11
+ * @author Alex Goldring
12
+ * @copyright Company Named Limited (c) 2026
13
+ */
14
+ export class BoxShape3D extends AbstractShape3D {
15
+ /**
16
+ * Convenience constructor.
17
+ * @param {number} hx
18
+ * @param {number} hy
19
+ * @param {number} hz
20
+ * @returns {BoxShape3D}
21
+ */
22
+ static from(hx: number, hy: number, hz: number): BoxShape3D;
23
+ /**
24
+ * Convenience constructor for boxes specified by full side lengths
25
+ * rather than half-extents.
26
+ * @param {number} width
27
+ * @param {number} height
28
+ * @param {number} depth
29
+ * @returns {BoxShape3D}
30
+ */
31
+ static from_size(width: number, height: number, depth: number): BoxShape3D;
32
+ /**
33
+ * Half-width / half-height / half-depth in the body's local frame.
34
+ * @readonly
35
+ * @type {Vector3}
36
+ */
37
+ readonly half_extents: Vector3;
38
+ compute_bounding_box(result: any): void;
39
+ nearest_point_on_surface(result: any, reference: any): void;
40
+ support(result: any, result_offset: any, direction_x: any, direction_y: any, direction_z: any): void;
41
+ signed_distance_gradient_at_point(result: any, point: any): number;
42
+ signed_distance_at_point(point: any): number;
43
+ contains_point(point: any): boolean;
44
+ sample_random_point_in_volume(result: any, result_offset: any, random: any): void;
45
+ /**
46
+ * @param {BoxShape3D} other
47
+ * @returns {boolean}
48
+ */
49
+ equals(other: BoxShape3D): boolean;
50
+ /**
51
+ * Fast type-check marker. Lets the physics narrowphase dispatch sphere-box
52
+ * and box-box pairs against arbitrary-half-extent boxes without an instanceof
53
+ * import or chain check. Read together with `shape.half_extents.x/y/z`.
54
+ * @readonly
55
+ * @type {boolean}
56
+ */
57
+ readonly isBoxShape3D: boolean;
58
+ }
59
+ import { AbstractShape3D } from "./AbstractShape3D.js";
60
+ import Vector3 from "../../Vector3.js";
61
+ //# sourceMappingURL=BoxShape3D.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BoxShape3D.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/shape/BoxShape3D.js"],"names":[],"mappings":"AAYA;;;;;;;;;;;;GAYG;AACH;IAYI;;;;;;OAMG;IACH,gBALW,MAAM,MACN,MAAM,MACN,MAAM,GACJ,UAAU,CAMtB;IAED;;;;;;;OAOG;IACH,wBALW,MAAM,UACN,MAAM,SACN,MAAM,GACJ,UAAU,CAItB;IA/BG;;;;OAIG;IACH,uBAFU,OAAO,CAE6B;IAsClD,wCAIC;IAED,4DAQC;IAED,qGAKC;IAED,mEAEC;IAED,6CAaC;IAED,oCAQC;IAED,kFAOC;IAED;;;OAGG;IACH,cAHW,UAAU,GACR,OAAO,CAInB;IAWL;;;;;;OAMG;IACH,uBAFU,OAAO,CAEgB;CAThC;gCA3I+B,sBAAsB;oBATlC,kBAAkB"}
@@ -0,0 +1,158 @@
1
+ import Vector3 from "../../Vector3.js";
2
+ import { max2 } from "../../../math/max2.js";
3
+ import { max3 } from "../../../math/max3.js";
4
+ import { min2 } from "../../../math/min2.js";
5
+ import { sign_not_zero } from "../../../math/sign_not_zero.js";
6
+ import { computeHashFloat } from "../../../primitives/numbers/computeHashFloat.js";
7
+ import { randomPointInBox } from "../../random/randomPointInBox.js";
8
+ import { v3_length } from "../../vec3/v3_length.js";
9
+ import { aabb3_nearest_point_on_surface } from "../aabb/aabb3_nearest_point_on_surface.js";
10
+ import { AbstractShape3D } from "./AbstractShape3D.js";
11
+ import { compute_signed_distance_gradient_by_sampling } from "./util/compute_signed_distance_gradient_by_sampling.js";
12
+
13
+ /**
14
+ * Axis-aligned box of arbitrary half-extents, expressed in the body's local
15
+ * frame. The shape spans `[-half_extents.x, +half_extents.x]` along X and
16
+ * symmetrically on Y / Z.
17
+ *
18
+ * This is the generalisation of {@link UnitCubeShape3D} (which is fixed to
19
+ * `0.5` per axis). The physics narrowphase recognises both via the shared
20
+ * `isBoxShape3D` prototype marker and reads `half_extents.x / y / z` to feed
21
+ * the closed-form sphere-box and box-box paths.
22
+ *
23
+ * @author Alex Goldring
24
+ * @copyright Company Named Limited (c) 2026
25
+ */
26
+ export class BoxShape3D extends AbstractShape3D {
27
+ constructor() {
28
+ super();
29
+
30
+ /**
31
+ * Half-width / half-height / half-depth in the body's local frame.
32
+ * @readonly
33
+ * @type {Vector3}
34
+ */
35
+ this.half_extents = new Vector3(0.5, 0.5, 0.5);
36
+ }
37
+
38
+ /**
39
+ * Convenience constructor.
40
+ * @param {number} hx
41
+ * @param {number} hy
42
+ * @param {number} hz
43
+ * @returns {BoxShape3D}
44
+ */
45
+ static from(hx, hy, hz) {
46
+ const b = new BoxShape3D();
47
+ b.half_extents.set(hx, hy, hz);
48
+ return b;
49
+ }
50
+
51
+ /**
52
+ * Convenience constructor for boxes specified by full side lengths
53
+ * rather than half-extents.
54
+ * @param {number} width
55
+ * @param {number} height
56
+ * @param {number} depth
57
+ * @returns {BoxShape3D}
58
+ */
59
+ static from_size(width, height, depth) {
60
+ return BoxShape3D.from(width * 0.5, height * 0.5, depth * 0.5);
61
+ }
62
+
63
+ get volume() {
64
+ const h = this.half_extents;
65
+ return 8 * h.x * h.y * h.z;
66
+ }
67
+
68
+ get surface_area() {
69
+ const h = this.half_extents;
70
+ return 8 * (h.x * h.y + h.y * h.z + h.z * h.x);
71
+ }
72
+
73
+ compute_bounding_box(result) {
74
+ const h = this.half_extents;
75
+ result[0] = -h.x; result[1] = -h.y; result[2] = -h.z;
76
+ result[3] = h.x; result[4] = h.y; result[5] = h.z;
77
+ }
78
+
79
+ nearest_point_on_surface(result, reference) {
80
+ const h = this.half_extents;
81
+ aabb3_nearest_point_on_surface(
82
+ result,
83
+ -h.x, -h.y, -h.z,
84
+ h.x, h.y, h.z,
85
+ reference[0], reference[1], reference[2]
86
+ );
87
+ }
88
+
89
+ support(result, result_offset, direction_x, direction_y, direction_z) {
90
+ const h = this.half_extents;
91
+ result[result_offset] = sign_not_zero(direction_x) * h.x;
92
+ result[result_offset + 1] = sign_not_zero(direction_y) * h.y;
93
+ result[result_offset + 2] = sign_not_zero(direction_z) * h.z;
94
+ }
95
+
96
+ signed_distance_gradient_at_point(result, point) {
97
+ return compute_signed_distance_gradient_by_sampling(result, this, point);
98
+ }
99
+
100
+ signed_distance_at_point(point) {
101
+ // SDF of an axis-aligned box centred at origin. Same closed form as
102
+ // UnitCubeShape3D but parametrised by half_extents.
103
+ const h = this.half_extents;
104
+ const q_x = Math.abs(point[0]) - h.x;
105
+ const q_y = Math.abs(point[1]) - h.y;
106
+ const q_z = Math.abs(point[2]) - h.z;
107
+
108
+ return v3_length(
109
+ max2(q_x, 0),
110
+ max2(q_y, 0),
111
+ max2(q_z, 0)
112
+ ) + min2(max3(q_x, q_y, q_z), 0);
113
+ }
114
+
115
+ contains_point(point) {
116
+ const h = this.half_extents;
117
+ const x = point[0];
118
+ const y = point[1];
119
+ const z = point[2];
120
+ return x > -h.x && x < h.x
121
+ && y > -h.y && y < h.y
122
+ && z > -h.z && z < h.z;
123
+ }
124
+
125
+ sample_random_point_in_volume(result, result_offset, random) {
126
+ randomPointInBox(random, result, result_offset);
127
+ const h = this.half_extents;
128
+ // randomPointInBox samples a unit cube — rescale to our half-extents.
129
+ result[result_offset] *= h.x * 2;
130
+ result[result_offset + 1] *= h.y * 2;
131
+ result[result_offset + 2] *= h.z * 2;
132
+ }
133
+
134
+ /**
135
+ * @param {BoxShape3D} other
136
+ * @returns {boolean}
137
+ */
138
+ equals(other) {
139
+ return super.equals(other) && this.half_extents.equals(other.half_extents);
140
+ }
141
+
142
+ hash() {
143
+ const h = this.half_extents;
144
+ const a = computeHashFloat(h.x);
145
+ const b = computeHashFloat(h.y);
146
+ const c = computeHashFloat(h.z);
147
+ return ((a * 31 + b) * 31 + c) | 0;
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Fast type-check marker. Lets the physics narrowphase dispatch sphere-box
153
+ * and box-box pairs against arbitrary-half-extent boxes without an instanceof
154
+ * import or chain check. Read together with `shape.half_extents.x/y/z`.
155
+ * @readonly
156
+ * @type {boolean}
157
+ */
158
+ BoxShape3D.prototype.isBoxShape3D = true;
@@ -32,6 +32,17 @@ export class CapsuleShape3D extends AbstractShape3D {
32
32
  * @returns {boolean}
33
33
  */
34
34
  equals(other: CapsuleShape3D): boolean;
35
+ /**
36
+ * Fast type-check marker, mirroring `UnitSphereShape3D.prototype.isUnitSphereShape3D`
37
+ * and `BoxShape3D.prototype.isBoxShape3D`. Lets the physics narrowphase
38
+ * dispatch capsule-sphere / capsule-capsule / capsule-box pairs to
39
+ * closed-form helpers (capsule = Minkowski sum of segment + sphere; all
40
+ * three reduce to point-or-segment distance queries that GJK+EPA struggles
41
+ * with on a smooth surface).
42
+ * @readonly
43
+ * @type {boolean}
44
+ */
45
+ readonly isCapsuleShape3D: boolean;
35
46
  }
36
47
  import { AbstractShape3D } from "./AbstractShape3D.js";
37
48
  //# sourceMappingURL=CapsuleShape3D.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CapsuleShape3D.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/shape/CapsuleShape3D.js"],"names":[],"mappings":"AAYA;;;;GAIG;AACH;IAiBI;;;;OAIG;IACH,oBAJW,MAAM,UACN,MAAM,GACJ,cAAc,CAa1B;IA7BG;;;OAGG;IACH,QAFU,MAAM,CAEC;IAEjB;;;OAGG;IACH,QAFU,MAAM,CAED;IAqCnB,wCAUC;IAED,6CAaC;IAED,mEAEC;IAED,oCAcC;IAED,4DA+BC;IAED,qGAUC;IAED,kFA+BC;IAED;;;OAGG;IACH,cAHW,cAAc,GACZ,OAAO,CAMnB;CAQJ;gCA1M+B,sBAAsB"}
1
+ {"version":3,"file":"CapsuleShape3D.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/shape/CapsuleShape3D.js"],"names":[],"mappings":"AAYA;;;;GAIG;AACH;IAiBI;;;;OAIG;IACH,oBAJW,MAAM,UACN,MAAM,GACJ,cAAc,CAa1B;IA7BG;;;OAGG;IACH,QAFU,MAAM,CAEC;IAEjB;;;OAGG;IACH,QAFU,MAAM,CAED;IAqCnB,wCAUC;IAED,6CAaC;IAED,mEAEC;IAED,oCAcC;IAED,4DA+BC;IAED,qGAUC;IAED,kFA+BC;IAED;;;OAGG;IACH,cAHW,cAAc,GACZ,OAAO,CAMnB;IAUL;;;;;;;;;OASG;IACH,2BAFU,OAAO,CAEwB;CAZxC;gCA1M+B,sBAAsB"}
@@ -208,3 +208,15 @@ export class CapsuleShape3D extends AbstractShape3D {
208
208
  return ((a << 5) - a + b) | 0;
209
209
  }
210
210
  }
211
+
212
+ /**
213
+ * Fast type-check marker, mirroring `UnitSphereShape3D.prototype.isUnitSphereShape3D`
214
+ * and `BoxShape3D.prototype.isBoxShape3D`. Lets the physics narrowphase
215
+ * dispatch capsule-sphere / capsule-capsule / capsule-box pairs to
216
+ * closed-form helpers (capsule = Minkowski sum of segment + sphere; all
217
+ * three reduce to point-or-segment distance queries that GJK+EPA struggles
218
+ * with on a smooth surface).
219
+ * @readonly
220
+ * @type {boolean}
221
+ */
222
+ CapsuleShape3D.prototype.isCapsuleShape3D = true;
@@ -1,12 +1,40 @@
1
- export class UnitCubeShape3D extends AbstractShape3D {
1
+ /**
2
+ * Unit cube centred at the origin, spanning `[-0.5, 0.5]` on every axis.
3
+ *
4
+ * @deprecated Use {@link BoxShape3D} instead — UnitCubeShape3D is now a thin
5
+ * subclass that just pins `half_extents` to `(0.5, 0.5, 0.5)`. All geometry
6
+ * (`support`, `signed_distance_at_point`, `volume`, `surface_area`,
7
+ * `nearest_point_on_surface`, ...) is inherited from {@link BoxShape3D}.
8
+ *
9
+ * Kept only for:
10
+ * - the `UnitCubeShape3D.INSTANCE` shared singleton that scenes and tests
11
+ * embed by reference
12
+ * - the JSON `'cube'` type-tag round-trip in `shape_to_type` /
13
+ * `type_adapters` (an `instanceof` check, which is why we still need a
14
+ * distinct subclass rather than a constant `BoxShape3D` instance)
15
+ *
16
+ * For new code prefer:
17
+ * - `new BoxShape3D()` — also defaults to half-extents `(0.5, 0.5, 0.5)`
18
+ * - `BoxShape3D.from_size(w, h, d)` — express by full side lengths
19
+ * - `BoxShape3D.from(hx, hy, hz)` — express by half-extents
20
+ */
21
+ export class UnitCubeShape3D extends BoxShape3D {
22
+ /**
23
+ * Shared singleton. Many call sites — JSON deserialisation, tests,
24
+ * `TransformedShape3D.from_translation(UnitCubeShape3D.INSTANCE, ...)`
25
+ * — embed this by reference rather than allocating a fresh cube.
26
+ * @type {UnitCubeShape3D}
27
+ */
2
28
  static INSTANCE: UnitCubeShape3D;
3
- compute_bounding_box(result: any): void;
4
- nearest_point_on_surface(result: any, reference: any): void;
5
- support(result: any, result_offset: any, direction_x: any, direction_y: any, direction_z: any): void;
6
- signed_distance_gradient_at_point(result: any, point: any): number;
7
- signed_distance_at_point(point: any): number;
8
- contains_point(point: any): boolean;
9
- sample_random_point_in_volume(result: any, result_offset: any, random: any): void;
29
+ /**
30
+ * @deprecated Prefer dispatching on `isBoxShape3D`, which is `true` for both
31
+ * UnitCubeShape3D (inherited via prototype chain) and {@link BoxShape3D}.
32
+ * Retained so any older external code that already narrowed via this marker
33
+ * keeps working.
34
+ * @readonly
35
+ * @type {boolean}
36
+ */
37
+ readonly isUnitCubeShape3D: boolean;
10
38
  }
11
- import { AbstractShape3D } from "./AbstractShape3D.js";
39
+ import { BoxShape3D } from "./BoxShape3D.js";
12
40
  //# sourceMappingURL=UnitCubeShape3D.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnitCubeShape3D.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/shape/UnitCubeShape3D.js"],"names":[],"mappings":"AAUA;IAsFI,iCAAwC;IA5ExC,wCAQC;IAED,4DAYC;IAED,qGAIC;IAED,mEAEC;IAED,6CAqBC;IAED,oCASC;IAED,kFAEC;CAOJ;gCA1F+B,sBAAsB"}
1
+ {"version":3,"file":"UnitCubeShape3D.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/shape/UnitCubeShape3D.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IAKI;;;;;OAKG;IACH,iBAFU,eAAe,CAEe;IAG5C;;;;;;;OAOG;IACH,4BAFU,OAAO,CAE0B;CAV1C;2BAlC0B,iBAAiB"}
@@ -1,98 +1,45 @@
1
- import { max2 } from "../../../math/max2.js";
2
- import { max3 } from "../../../math/max3.js";
3
- import { min2 } from "../../../math/min2.js";
4
- import { sign_not_zero } from "../../../math/sign_not_zero.js";
5
- import { randomPointInBox } from "../../random/randomPointInBox.js";
6
- import { v3_length } from "../../vec3/v3_length.js";
7
- import { aabb3_nearest_point_on_surface } from "../aabb/aabb3_nearest_point_on_surface.js";
8
- import { AbstractShape3D } from "./AbstractShape3D.js";
9
- import { compute_signed_distance_gradient_by_sampling } from "./util/compute_signed_distance_gradient_by_sampling.js";
10
-
11
- export class UnitCubeShape3D extends AbstractShape3D {
12
-
13
- get volume() {
14
- return 1;
15
- }
16
-
17
- get surface_area() {
18
- return 6;
19
- }
20
-
21
- compute_bounding_box(result) {
22
- result[0] = -0.5;
23
- result[1] = -0.5;
24
- result[2] = -0.5;
25
-
26
- result[3] = 0.5;
27
- result[4] = 0.5;
28
- result[5] = 0.5;
29
- }
30
-
31
- nearest_point_on_surface(result, reference) {
32
- const r_x = reference[0];
33
- const r_y = reference[1];
34
- const r_z = reference[2];
35
-
36
- aabb3_nearest_point_on_surface(
37
- result,
38
- -0.5, -0.5, -0.5,
39
- 0.5, 0.5, 0.5,
40
- r_x, r_y, r_z
41
- );
42
-
43
- }
44
-
45
- support(result, result_offset, direction_x, direction_y, direction_z) {
46
- result[result_offset] = sign_not_zero(direction_x) * 0.5;
47
- result[result_offset + 1] = sign_not_zero(direction_y) * 0.5;
48
- result[result_offset + 2] = sign_not_zero(direction_z) * 0.5;
49
- }
50
-
51
- signed_distance_gradient_at_point(result, point) {
52
- return compute_signed_distance_gradient_by_sampling(result, this, point);
53
- }
54
-
55
- signed_distance_at_point(point) {
56
- /*
57
- based on https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm
58
- original shader code:
59
- ------------
60
- float sdBox( vec3 p, vec3 b )
61
- {
62
- vec3 q = abs(p) - b;
63
- return length(max(q,0.0)) + min(max(q.x,max(q.y,q.z)),0.0);
64
- }
65
- ------------
66
- */
67
- const q_x = Math.abs(point[0]) - 0.5;
68
- const q_y = Math.abs(point[1]) - 0.5;
69
- const q_z = Math.abs(point[2]) - 0.5;
70
-
71
- return v3_length(
72
- max2(q_x, 0),
73
- max2(q_y, 0),
74
- max2(q_z, 0)
75
- ) + min2(max3(q_x, q_y, q_z), 0);
76
- }
77
-
78
- contains_point(point) {
79
- const x = point[0];
80
- const y = point[1];
81
- const z = point[2];
82
-
83
- return x > -0.5 && x < 0.5
84
- && y > -0.5 && y < 0.5
85
- && z > -0.5 && z < 0.5
86
- ;
87
- }
88
-
89
- sample_random_point_in_volume(result, result_offset, random) {
90
- randomPointInBox(random, result, result_offset);
91
- }
92
-
93
- hash() {
94
- return 1;
95
- }
96
-
97
- static INSTANCE = new UnitCubeShape3D();
98
- }
1
+ import { BoxShape3D } from "./BoxShape3D.js";
2
+
3
+ /**
4
+ * Unit cube centred at the origin, spanning `[-0.5, 0.5]` on every axis.
5
+ *
6
+ * @deprecated Use {@link BoxShape3D} instead — UnitCubeShape3D is now a thin
7
+ * subclass that just pins `half_extents` to `(0.5, 0.5, 0.5)`. All geometry
8
+ * (`support`, `signed_distance_at_point`, `volume`, `surface_area`,
9
+ * `nearest_point_on_surface`, ...) is inherited from {@link BoxShape3D}.
10
+ *
11
+ * Kept only for:
12
+ * - the `UnitCubeShape3D.INSTANCE` shared singleton that scenes and tests
13
+ * embed by reference
14
+ * - the JSON `'cube'` type-tag round-trip in `shape_to_type` /
15
+ * `type_adapters` (an `instanceof` check, which is why we still need a
16
+ * distinct subclass rather than a constant `BoxShape3D` instance)
17
+ *
18
+ * For new code prefer:
19
+ * - `new BoxShape3D()` — also defaults to half-extents `(0.5, 0.5, 0.5)`
20
+ * - `BoxShape3D.from_size(w, h, d)` — express by full side lengths
21
+ * - `BoxShape3D.from(hx, hy, hz)` — express by half-extents
22
+ */
23
+ export class UnitCubeShape3D extends BoxShape3D {
24
+ // No constructor / no method overrides on purpose. BoxShape3D's
25
+ // constructor already sets half_extents to (0.5, 0.5, 0.5), and every
26
+ // geometry method is correct for that case verbatim.
27
+
28
+ /**
29
+ * Shared singleton. Many call sites — JSON deserialisation, tests,
30
+ * `TransformedShape3D.from_translation(UnitCubeShape3D.INSTANCE, ...)`
31
+ * — embed this by reference rather than allocating a fresh cube.
32
+ * @type {UnitCubeShape3D}
33
+ */
34
+ static INSTANCE = new UnitCubeShape3D();
35
+ }
36
+
37
+ /**
38
+ * @deprecated Prefer dispatching on `isBoxShape3D`, which is `true` for both
39
+ * UnitCubeShape3D (inherited via prototype chain) and {@link BoxShape3D}.
40
+ * Retained so any older external code that already narrowed via this marker
41
+ * keeps working.
42
+ * @readonly
43
+ * @type {boolean}
44
+ */
45
+ UnitCubeShape3D.prototype.isUnitCubeShape3D = true;
@@ -9,6 +9,16 @@ export class UnitSphereShape3D extends AbstractShape3D {
9
9
  signed_distance_at_point(point: any): number;
10
10
  contains_point(point: any): boolean;
11
11
  sample_random_point_in_volume(result: any, result_offset: any, random: any): void;
12
+ /**
13
+ * Fast type-check marker (mirrors {@link Transform.prototype.isTransform}). Lets
14
+ * downstream code dispatch on shape kind without instanceof / import coupling.
15
+ * Use case: physics narrowphase short-circuits sphere-sphere to a closed-form
16
+ * solution rather than running GJK+EPA on a smooth surface (which is the EPA
17
+ * degenerate case).
18
+ * @readonly
19
+ * @type {boolean}
20
+ */
21
+ readonly isUnitSphereShape3D: boolean;
12
22
  }
13
23
  export namespace UnitSphereShape3D {
14
24
  let INSTANCE: UnitSphereShape3D;
@@ -1 +1 @@
1
- {"version":3,"file":"UnitSphereShape3D.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/shape/UnitSphereShape3D.js"],"names":[],"mappings":"AAKA;;GAEG;AACH;IASI,qGAQC;IAED,wCAQC;IAED,4DAYC;IAED,mEAEC;IAED,6CAMC;IAED,oCAMC;IAED,kFAEC;CAKJ;;;;gCA5E+B,sBAAsB"}
1
+ {"version":3,"file":"UnitSphereShape3D.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/shape/UnitSphereShape3D.js"],"names":[],"mappings":"AAKA;;GAEG;AACH;IASI,qGAQC;IAED,wCAQC;IAED,4DAYC;IAED,mEAEC;IAED,6CAMC;IAED,oCAMC;IAED,kFAEC;IASL;;;;;;;;OAQG;IACH,8BAFU,OAAO,CAE8B;CAb9C;;;;gCA5E+B,sBAAsB"}
@@ -79,3 +79,14 @@ export class UnitSphereShape3D extends AbstractShape3D {
79
79
  }
80
80
 
81
81
  UnitSphereShape3D.INSTANCE = new UnitSphereShape3D();
82
+
83
+ /**
84
+ * Fast type-check marker (mirrors {@link Transform.prototype.isTransform}). Lets
85
+ * downstream code dispatch on shape kind without instanceof / import coupling.
86
+ * Use case: physics narrowphase short-circuits sphere-sphere to a closed-form
87
+ * solution rather than running GJK+EPA on a smooth surface (which is the EPA
88
+ * degenerate case).
89
+ * @readonly
90
+ * @type {boolean}
91
+ */
92
+ UnitSphereShape3D.prototype.isUnitSphereShape3D = true;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Rasterize an {@link AbstractShape3D} into a cell-centered Uint8 grid mask.
3
+ *
4
+ * For each integer cell `(i, j, k)` in `[0, rx) × [0, ry) × [0, rz)`, the cell's
5
+ * center is recovered as the world-space point `grid_to_world * (i, j, k)`. If
6
+ * that point lies inside the shape — or close enough to its surface (see below)
7
+ * — the corresponding cell in `grid` is written as `1`.
8
+ *
9
+ * The grid is **not** cleared first. Cells outside the shape (and outside its
10
+ * proximity band) are left exactly as they were, which lets the caller compose
11
+ * multiple shapes into the same buffer by calling this function repeatedly. The
12
+ * caller is responsible for `grid.fill(0)` if a fresh mask is desired.
13
+ *
14
+ * **Proximity test.** A cell whose centre is outside the shape is still marked
15
+ * solid if `signed_distance_at_point(centre) < half_cell_diagonal`. This catches
16
+ * features that pass through a cell without containing its centre — e.g. a thin
17
+ * sheet bisecting a cubic cell at 45°. The threshold is the largest possible
18
+ * distance from a cell's centre to any point inside the cell, so any shape that
19
+ * intersects the cell at all is captured. Cheap fast path: `contains_point` is
20
+ * tested first (no sqrt for most shapes); the more expensive signed-distance
21
+ * call only runs for cells whose centre is outside.
22
+ *
23
+ * **Volume guard.** If the shape's total volume is less than half the volume of
24
+ * a single cell, the function returns immediately without writing anything. A
25
+ * shape that small can't be meaningfully represented as a unit-cell solid — the
26
+ * obstacle would end up perceptibly larger than the shape itself. Callers with
27
+ * sub-cell shapes should either refine the grid or use a different
28
+ * representation (e.g. a point-velocity effector).
29
+ *
30
+ * **Coord space.** `shape.contains_point` / `signed_distance_at_point` are
31
+ * called with **world** coordinates. For shapes that have their own local frame
32
+ * (e.g. `UnitSphereShape3D` centred at the origin), wrap them in a
33
+ * {@link TransformedShape3D} so they sit at the right world position before
34
+ * passing in. The voxelizer is otherwise agnostic to how the shape interprets
35
+ * its inputs.
36
+ *
37
+ * **Grid orientation.** `world_to_grid` and `grid_to_world` are full 4×4
38
+ * column-major affines, so the grid can be translated, scaled, or rotated in
39
+ * world space; the algorithm makes no axis-aligned assumption. Cell size per
40
+ * axis is recovered from the column lengths of `grid_to_world`, which is exact
41
+ * for orthogonal grids and an overestimate of cell volume for skewed ones — the
42
+ * latter only widens the volume-guard threshold, which is conservative.
43
+ *
44
+ * Designed to feed e.g. a fluid simulator's solid mask, but lives outside any
45
+ * specific package: anything that needs "rasterize a shape into a cell-centered
46
+ * boolean grid" can use it.
47
+ *
48
+ * @param {AbstractShape3D} shape shape to voxelize; `contains_point` and
49
+ * `signed_distance_at_point` are invoked with world-space points.
50
+ * @param {Float32Array|number[]} world_to_grid column-major 4×4 affine;
51
+ * world point → grid (cell-index) coords.
52
+ * @param {Float32Array|number[]} grid_to_world column-major 4×4 affine;
53
+ * grid (cell-index) coords → world cell center.
54
+ * @param {Uint8Array} grid output mask, length must be ≥ `rx * ry * rz`.
55
+ * Cells that don't pass the test are left untouched.
56
+ * @param {number} rx positive integer.
57
+ * @param {number} ry positive integer.
58
+ * @param {number} rz positive integer.
59
+ */
60
+ export function shape3d_voxelize_to_grid(shape: AbstractShape3D, world_to_grid: Float32Array | number[], grid_to_world: Float32Array | number[], grid: Uint8Array, rx: number, ry: number, rz: number): void;
61
+ //# sourceMappingURL=shape3d_voxelize_to_grid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shape3d_voxelize_to_grid.d.ts","sourceRoot":"","sources":["../../../../../../../src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,gFAVW,YAAY,GAAC,MAAM,EAAE,iBAErB,YAAY,GAAC,MAAM,EAAE,QAErB,UAAU,MAEV,MAAM,MACN,MAAM,MACN,MAAM,QA6EhB"}