@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,148 @@
1
+ import { assert } from "../../../../assert.js";
2
+ import { v3_length } from "../../../vec3/v3_length.js";
3
+ import { v3_matrix4_multiply } from "../../../vec3/v3_matrix4_multiply.js";
4
+ import { aabb3_matrix4_project } from "../../aabb/aabb3_matrix4_project.js";
5
+
6
+ // Reusable per-call scratch — keeps the function allocation-free under repeat
7
+ // invocations (which is the expected pattern: re-voxelize the scene every frame
8
+ // before stepping a simulation).
9
+ const _scratch_aabb_world = new Float32Array(6);
10
+ const _scratch_aabb_grid = new Float32Array(6);
11
+ const _scratch_grid_pt = new Float32Array(3);
12
+ const _scratch_world_pt = new Float32Array(3);
13
+
14
+ /**
15
+ * Rasterize an {@link AbstractShape3D} into a cell-centered Uint8 grid mask.
16
+ *
17
+ * For each integer cell `(i, j, k)` in `[0, rx) × [0, ry) × [0, rz)`, the cell's
18
+ * center is recovered as the world-space point `grid_to_world * (i, j, k)`. If
19
+ * that point lies inside the shape — or close enough to its surface (see below)
20
+ * — the corresponding cell in `grid` is written as `1`.
21
+ *
22
+ * The grid is **not** cleared first. Cells outside the shape (and outside its
23
+ * proximity band) are left exactly as they were, which lets the caller compose
24
+ * multiple shapes into the same buffer by calling this function repeatedly. The
25
+ * caller is responsible for `grid.fill(0)` if a fresh mask is desired.
26
+ *
27
+ * **Proximity test.** A cell whose centre is outside the shape is still marked
28
+ * solid if `signed_distance_at_point(centre) < half_cell_diagonal`. This catches
29
+ * features that pass through a cell without containing its centre — e.g. a thin
30
+ * sheet bisecting a cubic cell at 45°. The threshold is the largest possible
31
+ * distance from a cell's centre to any point inside the cell, so any shape that
32
+ * intersects the cell at all is captured. Cheap fast path: `contains_point` is
33
+ * tested first (no sqrt for most shapes); the more expensive signed-distance
34
+ * call only runs for cells whose centre is outside.
35
+ *
36
+ * **Volume guard.** If the shape's total volume is less than half the volume of
37
+ * a single cell, the function returns immediately without writing anything. A
38
+ * shape that small can't be meaningfully represented as a unit-cell solid — the
39
+ * obstacle would end up perceptibly larger than the shape itself. Callers with
40
+ * sub-cell shapes should either refine the grid or use a different
41
+ * representation (e.g. a point-velocity effector).
42
+ *
43
+ * **Coord space.** `shape.contains_point` / `signed_distance_at_point` are
44
+ * called with **world** coordinates. For shapes that have their own local frame
45
+ * (e.g. `UnitSphereShape3D` centred at the origin), wrap them in a
46
+ * {@link TransformedShape3D} so they sit at the right world position before
47
+ * passing in. The voxelizer is otherwise agnostic to how the shape interprets
48
+ * its inputs.
49
+ *
50
+ * **Grid orientation.** `world_to_grid` and `grid_to_world` are full 4×4
51
+ * column-major affines, so the grid can be translated, scaled, or rotated in
52
+ * world space; the algorithm makes no axis-aligned assumption. Cell size per
53
+ * axis is recovered from the column lengths of `grid_to_world`, which is exact
54
+ * for orthogonal grids and an overestimate of cell volume for skewed ones — the
55
+ * latter only widens the volume-guard threshold, which is conservative.
56
+ *
57
+ * Designed to feed e.g. a fluid simulator's solid mask, but lives outside any
58
+ * specific package: anything that needs "rasterize a shape into a cell-centered
59
+ * boolean grid" can use it.
60
+ *
61
+ * @param {AbstractShape3D} shape shape to voxelize; `contains_point` and
62
+ * `signed_distance_at_point` are invoked with world-space points.
63
+ * @param {Float32Array|number[]} world_to_grid column-major 4×4 affine;
64
+ * world point → grid (cell-index) coords.
65
+ * @param {Float32Array|number[]} grid_to_world column-major 4×4 affine;
66
+ * grid (cell-index) coords → world cell center.
67
+ * @param {Uint8Array} grid output mask, length must be ≥ `rx * ry * rz`.
68
+ * Cells that don't pass the test are left untouched.
69
+ * @param {number} rx positive integer.
70
+ * @param {number} ry positive integer.
71
+ * @param {number} rz positive integer.
72
+ */
73
+ export function shape3d_voxelize_to_grid(shape, world_to_grid, grid_to_world, grid, rx, ry, rz) {
74
+ assert.defined(shape, "shape");
75
+ assert.isArrayLike(world_to_grid, "world_to_grid");
76
+ assert.greaterThanOrEqual(world_to_grid.length, 16, "world_to_grid.length");
77
+ assert.isArrayLike(grid_to_world, "grid_to_world");
78
+ assert.greaterThanOrEqual(grid_to_world.length, 16, "grid_to_world.length");
79
+ assert.defined(grid, "grid");
80
+ assert.isPositiveInteger(rx, "rx");
81
+ assert.isPositiveInteger(ry, "ry");
82
+ assert.isPositiveInteger(rz, "rz");
83
+ assert.greaterThanOrEqual(grid.length, rx * ry * rz, "grid.length");
84
+
85
+ // Recover per-axis cell size from the column lengths of grid_to_world. For
86
+ // an axis-aligned uniform grid these are just the cell spacings; for an
87
+ // oriented grid they're the post-rotation lengths, which still bound the
88
+ // cell extent correctly.
89
+ const cs_x = v3_length(grid_to_world[0], grid_to_world[1], grid_to_world[2]);
90
+ const cs_y = v3_length(grid_to_world[4], grid_to_world[5], grid_to_world[6]);
91
+ const cs_z = v3_length(grid_to_world[8], grid_to_world[9], grid_to_world[10]);
92
+ const cell_volume = cs_x * cs_y * cs_z;
93
+
94
+ // Volume guard. See docstring — sub-cell shapes are skipped wholesale.
95
+ if (shape.volume < cell_volume * 0.5) {
96
+ return;
97
+ }
98
+
99
+ // Proximity threshold = half the cell diagonal in world units. Any shape
100
+ // whose surface comes within this radius of a cell centre might intersect
101
+ // the cell; this is the tightest threshold that won't miss grazing
102
+ // features.
103
+ const proximity_threshold = Math.sqrt(cs_x * cs_x + cs_y * cs_y + cs_z * cs_z) * 0.5;
104
+
105
+ // Restrict iteration to the shape's bounding box transformed into grid
106
+ // space, with a 1-cell expansion to cover the proximity band (the band is
107
+ // at most ~0.87 cells wide, so +1 cell on each side fully contains it).
108
+ shape.compute_bounding_box(_scratch_aabb_world);
109
+ aabb3_matrix4_project(_scratch_aabb_grid, _scratch_aabb_world, world_to_grid);
110
+
111
+ const i_min = Math.max(0, Math.floor(_scratch_aabb_grid[0]) - 1);
112
+ const j_min = Math.max(0, Math.floor(_scratch_aabb_grid[1]) - 1);
113
+ const k_min = Math.max(0, Math.floor(_scratch_aabb_grid[2]) - 1);
114
+ const i_max = Math.min(rx - 1, Math.ceil(_scratch_aabb_grid[3]) + 1);
115
+ const j_max = Math.min(ry - 1, Math.ceil(_scratch_aabb_grid[4]) + 1);
116
+ const k_max = Math.min(rz - 1, Math.ceil(_scratch_aabb_grid[5]) + 1);
117
+
118
+ // Bounding box lies entirely outside the grid → nothing to do.
119
+ if (i_min > i_max || j_min > j_max || k_min > k_max) {
120
+ return;
121
+ }
122
+
123
+ const rx_ry = rx * ry;
124
+ const grid_pt = _scratch_grid_pt;
125
+ const world_pt = _scratch_world_pt;
126
+
127
+ for (let k = k_min; k <= k_max; k++) {
128
+ grid_pt[2] = k;
129
+ const k_offset = k * rx_ry;
130
+ for (let j = j_min; j <= j_max; j++) {
131
+ grid_pt[1] = j;
132
+ const j_offset = k_offset + j * rx;
133
+ for (let i = i_min; i <= i_max; i++) {
134
+ grid_pt[0] = i;
135
+ v3_matrix4_multiply(world_pt, 0, grid_pt, 0, grid_to_world);
136
+
137
+ // contains_point is the cheap fast path (no sqrt for most
138
+ // shapes). Only fall through to signed_distance for cells whose
139
+ // centre is outside the shape, where we still might mark them
140
+ // for the proximity rule.
141
+ if (shape.contains_point(world_pt)
142
+ || shape.signed_distance_at_point(world_pt) < proximity_threshold) {
143
+ grid[j_offset + i] = 1;
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Tetrahedralize the volume enclosed by a triangle surface mesh. The result
3
+ * is a Delaunay tetrahedral mesh whose vertices are the surface's vertices
4
+ * (plus any hole-closing centroids and any opt-in interior Steiner points)
5
+ * and whose enclosed region approximates the surface's interior.
6
+ *
7
+ * The input is treated as airtight; any boundary holes are closed up front
8
+ * by fanning each boundary loop around its centroid (a Steiner vertex is
9
+ * added at each hole's centroid). The closed surface then drives the
10
+ * Delaunay input set and the inside/outside classification used to carve
11
+ * away exterior tets — non-convex shapes (e.g., Stanford bunny) are
12
+ * supported.
13
+ *
14
+ * The caller's surface mesh is not mutated; a clone is taken internally.
15
+ *
16
+ * Interior Steiner points are OFF by default. Pass a positive
17
+ * `interior_steiner_cells_per_dim` (e.g. ⌈cbrt(surface_vert_count)⌉) to
18
+ * fill the volume with interior detail — useful for FEM / simulation where
19
+ * thin sliver tets and surface-bound vertex distribution would hurt
20
+ * conditioning. Note that interior Steiner does NOT reduce the carving's
21
+ * volume gap (that comes from tets straddling the surface, and adding
22
+ * interior points doesn't shrink those); a tighter volume gap needs
23
+ * surface subdivision or true constraint-recovery, neither of which is
24
+ * implemented here.
25
+ *
26
+ * Interior Steiner can also HURT total volume on pathological inputs (two
27
+ * solids meeting at a single vertex, very thin hollow shells) — the
28
+ * Delaunay produces bridge tets across the pinch that carry legitimate
29
+ * interior on each side but whose centroids land in the void and get
30
+ * carved. Leave Steiner off (the default) for those cases.
31
+ *
32
+ * @param {TetrahedralMesh} tet_mesh empty, populated in place
33
+ * @param {BinaryTopology} surface triangle surface mesh, near-airtight
34
+ * @param {number} [interior_steiner_cells_per_dim] grid resolution along the
35
+ * longest bbox axis for interior Steiner sampling; 0 disables
36
+ * @returns {Float32Array} flat (x,y,z) positions array indexed by tet vertex ID
37
+ */
38
+ export function compute_tetrahedral_mesh_from_surface(tet_mesh: TetrahedralMesh, surface: BinaryTopology, interior_steiner_cells_per_dim?: number): Float32Array;
39
+ //# sourceMappingURL=compute_tetrahedral_mesh_from_surface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute_tetrahedral_mesh_from_surface.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.js"],"names":[],"mappings":"AAiCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,2IAJW,MAAM,GAEJ,YAAY,CA8ExB"}
@@ -0,0 +1,147 @@
1
+ import { assert } from "../../../assert.js";
2
+ import {
3
+ bt_mesh_fuse_duplicate_edges
4
+ } from "../topology/struct/binary/io/edge/bt_mesh_fuse_duplicate_edges.js";
5
+ import {
6
+ bt_mesh_kill_short_edges
7
+ } from "../topology/struct/binary/io/edge/bt_mesh_kill_short_edges.js";
8
+ import {
9
+ bt_mesh_cleanup_faceless_references
10
+ } from "../topology/struct/binary/io/bt_mesh_cleanup_faceless_references.js";
11
+ import {
12
+ bt_mesh_close_boundary_holes
13
+ } from "../topology/struct/binary/io/bt_mesh_close_boundary_holes.js";
14
+ import { bt_mesh_compact } from "../topology/struct/binary/io/bt_mesh_compact.js";
15
+ import {
16
+ bt_mesh_sample_interior_grid_points
17
+ } from "../topology/struct/binary/query/bt_mesh_sample_interior_grid_points.js";
18
+ import {
19
+ bt_merge_verts_by_distance
20
+ } from "../topology/struct/binary/io/vertex/bt_merge_verts_by_distance.js";
21
+ import { compute_delaunay_tetrahedral_mesh } from "./delaunay/compute_delaunay_tetrahedral_mesh.js";
22
+ import {
23
+ tetrahedral_mesh_carve_outside_surface
24
+ } from "./tetrahedral_mesh_carve_outside_surface.js";
25
+
26
+ // Default vertex-merge tolerance for the pre-tetrahedralization weld pass.
27
+ // Two surface vertices closer than this collapse to one; below this scale
28
+ // they would just create degenerate sliver tets anyway. Generous enough to
29
+ // soak up float32 round-trip drift; tight enough not to swallow real
30
+ // detail at typical model scales (Suzanne, cube, bunny, …).
31
+ const VERTEX_MERGE_DISTANCE = 1e-4;
32
+
33
+
34
+ /**
35
+ * Tetrahedralize the volume enclosed by a triangle surface mesh. The result
36
+ * is a Delaunay tetrahedral mesh whose vertices are the surface's vertices
37
+ * (plus any hole-closing centroids and any opt-in interior Steiner points)
38
+ * and whose enclosed region approximates the surface's interior.
39
+ *
40
+ * The input is treated as airtight; any boundary holes are closed up front
41
+ * by fanning each boundary loop around its centroid (a Steiner vertex is
42
+ * added at each hole's centroid). The closed surface then drives the
43
+ * Delaunay input set and the inside/outside classification used to carve
44
+ * away exterior tets — non-convex shapes (e.g., Stanford bunny) are
45
+ * supported.
46
+ *
47
+ * The caller's surface mesh is not mutated; a clone is taken internally.
48
+ *
49
+ * Interior Steiner points are OFF by default. Pass a positive
50
+ * `interior_steiner_cells_per_dim` (e.g. ⌈cbrt(surface_vert_count)⌉) to
51
+ * fill the volume with interior detail — useful for FEM / simulation where
52
+ * thin sliver tets and surface-bound vertex distribution would hurt
53
+ * conditioning. Note that interior Steiner does NOT reduce the carving's
54
+ * volume gap (that comes from tets straddling the surface, and adding
55
+ * interior points doesn't shrink those); a tighter volume gap needs
56
+ * surface subdivision or true constraint-recovery, neither of which is
57
+ * implemented here.
58
+ *
59
+ * Interior Steiner can also HURT total volume on pathological inputs (two
60
+ * solids meeting at a single vertex, very thin hollow shells) — the
61
+ * Delaunay produces bridge tets across the pinch that carry legitimate
62
+ * interior on each side but whose centroids land in the void and get
63
+ * carved. Leave Steiner off (the default) for those cases.
64
+ *
65
+ * @param {TetrahedralMesh} tet_mesh empty, populated in place
66
+ * @param {BinaryTopology} surface triangle surface mesh, near-airtight
67
+ * @param {number} [interior_steiner_cells_per_dim] grid resolution along the
68
+ * longest bbox axis for interior Steiner sampling; 0 disables
69
+ * @returns {Float32Array} flat (x,y,z) positions array indexed by tet vertex ID
70
+ */
71
+ export function compute_tetrahedral_mesh_from_surface(
72
+ tet_mesh,
73
+ surface,
74
+ interior_steiner_cells_per_dim = 0
75
+ ) {
76
+ assert.defined(tet_mesh, 'tet_mesh');
77
+ assert.equal(tet_mesh.isTetrahedralMesh, true, 'tet_mesh.isTetrahedralMesh !== true');
78
+ assert.defined(surface, 'surface');
79
+ assert.equal(surface.isBinaryTopology, true, 'surface.isBinaryTopology !== true');
80
+
81
+ const working_surface = surface.clone();
82
+
83
+ // Pre-pass: kill any edge whose endpoints are within VERTEX_MERGE_DISTANCE
84
+ // (and any pre-existing self-loops). If left in place, bt_merge_verts_by_distance
85
+ // would collapse the endpoints via bt_vertex_replace, which silently
86
+ // produces a self-loop edge (v1 === v2). That self-loop has its v1 and v2
87
+ // disk pointers in the same vertex's cycle, branching the cycle in a way
88
+ // that hangs the downstream bt_mesh_fuse_duplicate_edges walker. Killing
89
+ // the short edges up front (and cleaning the faceless rubble they leave)
90
+ // means the merge sees no direct-edge pairs and cannot make self-loops.
91
+ // The existing bt_mesh_simplify pipeline uses the same safety pattern via
92
+ // bt_edge_kill_parallels around each edge collapse.
93
+ bt_mesh_kill_short_edges(working_surface, VERTEX_MERGE_DISTANCE);
94
+ bt_mesh_cleanup_faceless_references(working_surface);
95
+
96
+ // GLTF (and most asset-pipeline outputs) duplicate per-corner attributes
97
+ // at smoothing/UV splits, so a "unit cube" arrives with 24 positions
98
+ // instead of 8 and every face-pair edge ends up as a boundary edge —
99
+ // hole closing then chokes on figure-8 pinch vertices and we yield zero
100
+ // tets. Merge coincident vertices; this is a no-op on a topology that
101
+ // already has unique positions.
102
+ bt_merge_verts_by_distance(working_surface, VERTEX_MERGE_DISTANCE);
103
+
104
+ // The merge only re-points edge endpoints; it doesn't fuse the now-parallel
105
+ // edges that share both endpoints. Without the fuse pass, each cube corner
106
+ // still has duplicate edges in its disk cycle and the boundary walker
107
+ // still sees it as a pinch. Fuse must follow merge.
108
+ bt_mesh_fuse_duplicate_edges(working_surface);
109
+
110
+ // Compact removes any dangling unallocated vertex / edge slots so vertex
111
+ // IDs are dense (required so the flat positions array index matches the
112
+ // BinaryTopology vertex ID after extraction).
113
+ bt_mesh_compact(working_surface);
114
+
115
+ bt_mesh_close_boundary_holes(working_surface);
116
+
117
+ const surface_vertex_count = working_surface.vertices.size;
118
+
119
+ // Interior Steiner points are opt-in. Caller chooses cells_per_dim — a
120
+ // sensible default for FEM-style usage is roughly cbrt(surface_vert_count)
121
+ // (interior point spacing matches surface vertex spacing).
122
+ const interior_positions = interior_steiner_cells_per_dim > 0
123
+ ? bt_mesh_sample_interior_grid_points(working_surface, interior_steiner_cells_per_dim)
124
+ : new Float32Array(0);
125
+ const interior_count = interior_positions.length / 3;
126
+
127
+ const total_count = surface_vertex_count + interior_count;
128
+ const positions = new Float32Array(total_count * 3);
129
+
130
+ const coord = [0, 0, 0];
131
+ for (let v = 0; v < surface_vertex_count; v++) {
132
+ working_surface.vertex_read_coordinate(coord, 0, v);
133
+ positions[v * 3] = coord[0];
134
+ positions[v * 3 + 1] = coord[1];
135
+ positions[v * 3 + 2] = coord[2];
136
+ }
137
+ positions.set(interior_positions, surface_vertex_count * 3);
138
+
139
+ const ok = compute_delaunay_tetrahedral_mesh(tet_mesh, positions, total_count);
140
+ if (!ok) {
141
+ return positions;
142
+ }
143
+
144
+ tetrahedral_mesh_carve_outside_surface(tet_mesh, positions, working_surface);
145
+
146
+ return positions;
147
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Mesh-form wrapper for {@link tetrahedron_compute_quality}: fetches the 4
3
+ * vertex IDs of `tet` and forwards to the indexed primitive.
4
+ *
5
+ * Sibling of {@link compute_tetrahedron_volume}; same convention (the
6
+ * `compute_*` prefix marks the mesh-bound form, the `tetrahedron_compute_*`
7
+ * prefix marks the indexed primitive).
8
+ *
9
+ * @param {TetrahedralMesh} mesh
10
+ * @param {ArrayLike<number>} points flat (x,y,z) positions
11
+ * @param {number} tet
12
+ * @returns {number} quality in [0, 1]
13
+ */
14
+ export function compute_tetrahedron_quality(mesh: TetrahedralMesh, points: ArrayLike<number>, tet: number): number;
15
+ //# sourceMappingURL=compute_tetrahedron_quality.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute_tetrahedron_quality.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,2EAJW,UAAU,MAAM,CAAC,OACjB,MAAM,GACJ,MAAM,CAQlB"}
@@ -0,0 +1,22 @@
1
+ import { tetrahedron_compute_quality } from "./tetrahedron_compute_quality.js";
2
+
3
+ /**
4
+ * Mesh-form wrapper for {@link tetrahedron_compute_quality}: fetches the 4
5
+ * vertex IDs of `tet` and forwards to the indexed primitive.
6
+ *
7
+ * Sibling of {@link compute_tetrahedron_volume}; same convention (the
8
+ * `compute_*` prefix marks the mesh-bound form, the `tetrahedron_compute_*`
9
+ * prefix marks the indexed primitive).
10
+ *
11
+ * @param {TetrahedralMesh} mesh
12
+ * @param {ArrayLike<number>} points flat (x,y,z) positions
13
+ * @param {number} tet
14
+ * @returns {number} quality in [0, 1]
15
+ */
16
+ export function compute_tetrahedron_quality(mesh, points, tet) {
17
+ const a = mesh.getVertexIndex(tet, 0);
18
+ const b = mesh.getVertexIndex(tet, 1);
19
+ const c = mesh.getVertexIndex(tet, 2);
20
+ const d = mesh.getVertexIndex(tet, 3);
21
+ return tetrahedron_compute_quality(points, a, b, c, d);
22
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=prototype_tetrahedrize_mesh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prototype_tetrahedrize_mesh.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.js"],"names":[],"mappings":""}