@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,23 @@
1
+ /**
2
+ * Semi-Lagrangian advection of a scalar field by a separate velocity field.
3
+ *
4
+ * For each cell, traces backward by `(vel_x, vel_y, vel_z) * time_delta` and trilinearly
5
+ * samples the input scalar at the back-traced position. Unconditionally stable for any
6
+ * timestep. Used to transport densities, temperatures, or any passive quantity by the
7
+ * flow.
8
+ *
9
+ * @param {Float32Array} output Destination, mutated. Length = res_x*res_y*res_z.
10
+ * @param {Float32Array} input Scalar values to advect. Must not alias `output`.
11
+ * @param {Float32Array} vel_x Velocity X component (cell-centered).
12
+ * @param {Float32Array} vel_y Velocity Y component (cell-centered).
13
+ * @param {Float32Array} vel_z Velocity Z component (cell-centered).
14
+ * @param {number} res_x
15
+ * @param {number} res_y
16
+ * @param {number} res_z
17
+ * @param {number} time_delta
18
+ * @param {Uint8Array} solid Required cell flags (zero-filled for a wall-free
19
+ * domain); solid cells get their input value
20
+ * passed through unchanged.
21
+ */
22
+ export function v3_grid_apply_scalar_advection(output: Float32Array, input: Float32Array, vel_x: Float32Array, vel_y: Float32Array, vel_z: Float32Array, res_x: number, res_y: number, res_z: number, time_delta: number, solid: Uint8Array): void;
23
+ //# sourceMappingURL=v3_grid_apply_scalar_advection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3_grid_apply_scalar_advection.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.js"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,uDAbW,YAAY,SACZ,YAAY,SACZ,YAAY,SACZ,YAAY,SACZ,YAAY,SACZ,MAAM,SACN,MAAM,SACN,MAAM,cACN,MAAM,SACN,UAAU,QAuCpB"}
@@ -0,0 +1,60 @@
1
+ import { assert } from "../../../../core/assert.js";
2
+ import { scs3d_sample_linear } from "../../../graphics/texture/3d/scs3d_sample_linear.js";
3
+
4
+ /**
5
+ * Semi-Lagrangian advection of a scalar field by a separate velocity field.
6
+ *
7
+ * For each cell, traces backward by `(vel_x, vel_y, vel_z) * time_delta` and trilinearly
8
+ * samples the input scalar at the back-traced position. Unconditionally stable for any
9
+ * timestep. Used to transport densities, temperatures, or any passive quantity by the
10
+ * flow.
11
+ *
12
+ * @param {Float32Array} output Destination, mutated. Length = res_x*res_y*res_z.
13
+ * @param {Float32Array} input Scalar values to advect. Must not alias `output`.
14
+ * @param {Float32Array} vel_x Velocity X component (cell-centered).
15
+ * @param {Float32Array} vel_y Velocity Y component (cell-centered).
16
+ * @param {Float32Array} vel_z Velocity Z component (cell-centered).
17
+ * @param {number} res_x
18
+ * @param {number} res_y
19
+ * @param {number} res_z
20
+ * @param {number} time_delta
21
+ * @param {Uint8Array} solid Required cell flags (zero-filled for a wall-free
22
+ * domain); solid cells get their input value
23
+ * passed through unchanged.
24
+ */
25
+ export function v3_grid_apply_scalar_advection(output, input, vel_x, vel_y, vel_z, res_x, res_y, res_z, time_delta, solid) {
26
+ assert.notEqual(output, input, "output must not alias input");
27
+
28
+ const cell_count = res_x * res_y * res_z;
29
+
30
+ assert.greaterThanOrEqual(output.length, cell_count, "output covers grid");
31
+ assert.greaterThanOrEqual(input.length, cell_count, "input covers grid");
32
+ assert.greaterThanOrEqual(vel_x.length, cell_count, "vel_x covers grid");
33
+ assert.greaterThanOrEqual(vel_y.length, cell_count, "vel_y covers grid");
34
+ assert.greaterThanOrEqual(vel_z.length, cell_count, "vel_z covers grid");
35
+
36
+ const slice_size = res_x * res_y;
37
+
38
+ for (let z = 0; z < res_z; z++) {
39
+ const z_off = z * slice_size;
40
+
41
+ for (let y = 0; y < res_y; y++) {
42
+ const y_off = y * res_x;
43
+
44
+ for (let x = 0; x < res_x; x++) {
45
+ const c = z_off + y_off + x;
46
+
47
+ if (solid[c] !== 0) {
48
+ output[c] = input[c];
49
+ continue;
50
+ }
51
+
52
+ const s_x = x - vel_x[c] * time_delta;
53
+ const s_y = y - vel_y[c] * time_delta;
54
+ const s_z = z - vel_z[c] * time_delta;
55
+
56
+ output[c] = scs3d_sample_linear(input, res_x, res_y, res_z, s_x, s_y, s_z);
57
+ }
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Compute the divergence of a cell-centered velocity field into a scalar field.
3
+ *
4
+ * div(c) ≈ 0.5 * ( u(x+1) - u(x-1) + v(y+1) - v(y-1) + w(z+1) - w(z-1) )
5
+ *
6
+ * Boundary cells use one-sided differences (`u(x+1) - u(x)` or `u(x) - u(x-1)`), keeping
7
+ * the scheme consistent for free outflow. Solid cells get divergence 0 — they are not
8
+ * fluid and don't participate in the pressure solve.
9
+ *
10
+ * Unit assumption: cell spacing h = 1 (positions are in grid units). If you advect with
11
+ * "world units per second" velocities, convert before calling.
12
+ *
13
+ * @param {Float32Array} divergence Destination, mutated.
14
+ * @param {Float32Array} vel_x
15
+ * @param {Float32Array} vel_y
16
+ * @param {Float32Array} vel_z
17
+ * @param {number} res_x
18
+ * @param {number} res_y
19
+ * @param {number} res_z
20
+ * @param {Uint8Array} solid Required (zero-filled for a wall-free domain).
21
+ */
22
+ export function v3_grid_compute_divergence(divergence: Float32Array, vel_x: Float32Array, vel_y: Float32Array, vel_z: Float32Array, res_x: number, res_y: number, res_z: number, solid: Uint8Array): void;
23
+ //# sourceMappingURL=v3_grid_compute_divergence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3_grid_compute_divergence.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/fluid/solver/v3_grid_compute_divergence.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,uDATW,YAAY,SACZ,YAAY,SACZ,YAAY,SACZ,YAAY,SACZ,MAAM,SACN,MAAM,SACN,MAAM,SACN,UAAU,QA8CpB"}
@@ -0,0 +1,68 @@
1
+ import { assert } from "../../../../core/assert.js";
2
+
3
+ /**
4
+ * Compute the divergence of a cell-centered velocity field into a scalar field.
5
+ *
6
+ * div(c) ≈ 0.5 * ( u(x+1) - u(x-1) + v(y+1) - v(y-1) + w(z+1) - w(z-1) )
7
+ *
8
+ * Boundary cells use one-sided differences (`u(x+1) - u(x)` or `u(x) - u(x-1)`), keeping
9
+ * the scheme consistent for free outflow. Solid cells get divergence 0 — they are not
10
+ * fluid and don't participate in the pressure solve.
11
+ *
12
+ * Unit assumption: cell spacing h = 1 (positions are in grid units). If you advect with
13
+ * "world units per second" velocities, convert before calling.
14
+ *
15
+ * @param {Float32Array} divergence Destination, mutated.
16
+ * @param {Float32Array} vel_x
17
+ * @param {Float32Array} vel_y
18
+ * @param {Float32Array} vel_z
19
+ * @param {number} res_x
20
+ * @param {number} res_y
21
+ * @param {number} res_z
22
+ * @param {Uint8Array} solid Required (zero-filled for a wall-free domain).
23
+ */
24
+ export function v3_grid_compute_divergence(divergence, vel_x, vel_y, vel_z, res_x, res_y, res_z, solid) {
25
+ const cell_count = res_x * res_y * res_z;
26
+ assert.greaterThanOrEqual(divergence.length, cell_count, "divergence covers grid");
27
+ assert.greaterThanOrEqual(vel_x.length, cell_count, "vel_x covers grid");
28
+ assert.greaterThanOrEqual(vel_y.length, cell_count, "vel_y covers grid");
29
+ assert.greaterThanOrEqual(vel_z.length, cell_count, "vel_z covers grid");
30
+
31
+ const slice_size = res_x * res_y;
32
+ const last_x = res_x - 1;
33
+ const last_y = res_y - 1;
34
+ const last_z = res_z - 1;
35
+
36
+ for (let z = 0; z < res_z; z++) {
37
+ const z_off = z * slice_size;
38
+
39
+ for (let y = 0; y < res_y; y++) {
40
+ const y_off = y * res_x;
41
+
42
+ for (let x = 0; x < res_x; x++) {
43
+ const c = z_off + y_off + x;
44
+
45
+ if (solid[c] !== 0) {
46
+ divergence[c] = 0;
47
+ continue;
48
+ }
49
+
50
+ let du, dv, dw;
51
+
52
+ if (x === 0) du = vel_x[c + 1] - vel_x[c];
53
+ else if (x === last_x) du = vel_x[c] - vel_x[c - 1];
54
+ else du = 0.5 * (vel_x[c + 1] - vel_x[c - 1]);
55
+
56
+ if (y === 0) dv = vel_y[c + res_x] - vel_y[c];
57
+ else if (y === last_y) dv = vel_y[c] - vel_y[c - res_x];
58
+ else dv = 0.5 * (vel_y[c + res_x] - vel_y[c - res_x]);
59
+
60
+ if (z === 0) dw = vel_z[c + slice_size] - vel_z[c];
61
+ else if (z === last_z) dw = vel_z[c] - vel_z[c - slice_size];
62
+ else dw = 0.5 * (vel_z[c + slice_size] - vel_z[c - slice_size]);
63
+
64
+ divergence[c] = du + dv + dw;
65
+ }
66
+ }
67
+ }
68
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Bake a per-cell neighbourhood mask describing which of the 6 cardinal
3
+ * neighbours of each cell are "fluid" (in-bounds AND non-solid). Consumed by
4
+ * {@link v3_grid_solve_pressure}, which uses the mask to skip boundary checks
5
+ * and solid-neighbour checks entirely.
6
+ *
7
+ * Encoding (one byte per cell, low 6 bits):
8
+ *
9
+ * bit 0 (= 1) : -x neighbour is fluid
10
+ * bit 1 (= 2) : +x neighbour is fluid
11
+ * bit 2 (= 4) : -y neighbour is fluid
12
+ * bit 3 (= 8) : +y neighbour is fluid
13
+ * bit 4 (= 16) : -z neighbour is fluid
14
+ * bit 5 (= 32) : +z neighbour is fluid
15
+ *
16
+ * Solid cells themselves are encoded as `mask = 0` (not "their own neighbours
17
+ * are fluid") so the SOR loop's `mask === 0 → skip` branch covers both
18
+ * "self-solid" and "fluid but no fluid neighbours" with one comparison.
19
+ *
20
+ * O(N) — one byte-write per cell, up to six byte-reads per cell. The output
21
+ * fully replaces whatever was in `mask` before; no need to zero-init.
22
+ *
23
+ * @param {Uint8Array} mask Destination. Length ≥ res_x*res_y*res_z.
24
+ * @param {Uint8Array} solid Source. Length ≥ res_x*res_y*res_z. Non-zero = solid.
25
+ * @param {number} res_x
26
+ * @param {number} res_y
27
+ * @param {number} res_z
28
+ */
29
+ export function v3_grid_compute_solid_neighbour_mask(mask: Uint8Array, solid: Uint8Array, res_x: number, res_y: number, res_z: number): void;
30
+ //# sourceMappingURL=v3_grid_compute_solid_neighbour_mask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3_grid_compute_solid_neighbour_mask.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,2DANW,UAAU,SACV,UAAU,SACV,MAAM,SACN,MAAM,SACN,MAAM,QAqChB"}
@@ -0,0 +1,66 @@
1
+ import { assert } from "../../../../core/assert.js";
2
+
3
+ /**
4
+ * Bake a per-cell neighbourhood mask describing which of the 6 cardinal
5
+ * neighbours of each cell are "fluid" (in-bounds AND non-solid). Consumed by
6
+ * {@link v3_grid_solve_pressure}, which uses the mask to skip boundary checks
7
+ * and solid-neighbour checks entirely.
8
+ *
9
+ * Encoding (one byte per cell, low 6 bits):
10
+ *
11
+ * bit 0 (= 1) : -x neighbour is fluid
12
+ * bit 1 (= 2) : +x neighbour is fluid
13
+ * bit 2 (= 4) : -y neighbour is fluid
14
+ * bit 3 (= 8) : +y neighbour is fluid
15
+ * bit 4 (= 16) : -z neighbour is fluid
16
+ * bit 5 (= 32) : +z neighbour is fluid
17
+ *
18
+ * Solid cells themselves are encoded as `mask = 0` (not "their own neighbours
19
+ * are fluid") so the SOR loop's `mask === 0 → skip` branch covers both
20
+ * "self-solid" and "fluid but no fluid neighbours" with one comparison.
21
+ *
22
+ * O(N) — one byte-write per cell, up to six byte-reads per cell. The output
23
+ * fully replaces whatever was in `mask` before; no need to zero-init.
24
+ *
25
+ * @param {Uint8Array} mask Destination. Length ≥ res_x*res_y*res_z.
26
+ * @param {Uint8Array} solid Source. Length ≥ res_x*res_y*res_z. Non-zero = solid.
27
+ * @param {number} res_x
28
+ * @param {number} res_y
29
+ * @param {number} res_z
30
+ */
31
+ export function v3_grid_compute_solid_neighbour_mask(mask, solid, res_x, res_y, res_z) {
32
+ const cells = res_x * res_y * res_z;
33
+ assert.greaterThanOrEqual(mask.length, cells, "mask covers grid");
34
+ assert.greaterThanOrEqual(solid.length, cells, "solid covers grid");
35
+
36
+ const slice = res_x * res_y;
37
+ const last_x = res_x - 1;
38
+ const last_y = res_y - 1;
39
+ const last_z = res_z - 1;
40
+
41
+ for (let z = 0; z < res_z; z++) {
42
+ const z_off = z * slice;
43
+ const has_zm = z > 0;
44
+ const has_zp = z < last_z;
45
+ for (let y = 0; y < res_y; y++) {
46
+ const y_off = z_off + y * res_x;
47
+ const has_ym = y > 0;
48
+ const has_yp = y < last_y;
49
+ for (let x = 0; x < res_x; x++) {
50
+ const c = y_off + x;
51
+ if (solid[c] !== 0) {
52
+ mask[c] = 0;
53
+ continue;
54
+ }
55
+ let m = 0;
56
+ if (x > 0 && solid[c - 1] === 0) m |= 1;
57
+ if (x < last_x && solid[c + 1] === 0) m |= 2;
58
+ if (has_ym && solid[c - res_x] === 0) m |= 4;
59
+ if (has_yp && solid[c + res_x] === 0) m |= 8;
60
+ if (has_zm && solid[c - slice] === 0) m |= 16;
61
+ if (has_zp && solid[c + slice] === 0) m |= 32;
62
+ mask[c] = m;
63
+ }
64
+ }
65
+ }
66
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Fill the edges exposed by {@link v3_grid_shift_in_place} (with the same
3
+ * `(shift_x, shift_y, shift_z)`) by replicating the adjacent valid column / row /
4
+ * slice — zero-gradient Neumann extrapolation, equivalent to "the field is locally
5
+ * uniform near the boundary".
6
+ *
7
+ * Axes are patched independently in x → y → z order. Corner cells (where two or
8
+ * three axis-edges meet) are written by every axis they belong to; the final value
9
+ * comes from the last axis, which sees the previously-patched cells as already-valid
10
+ * neighbours.
11
+ *
12
+ * No-ops:
13
+ * - All shifts zero → nothing to patch.
14
+ * - `|shift| >= res` on any axis → the shift primitive already zero-filled the
15
+ * buffer; nothing to replicate from.
16
+ *
17
+ * @param {Float32Array|Uint8Array} buffer
18
+ * @param {number} res_x
19
+ * @param {number} res_y
20
+ * @param {number} res_z
21
+ * @param {number} shift_x integer; same value passed to v3_grid_shift_in_place
22
+ * @param {number} shift_y integer
23
+ * @param {number} shift_z integer
24
+ */
25
+ export function v3_grid_patch_edges_uniform(buffer: Float32Array | Uint8Array, res_x: number, res_y: number, res_z: number, shift_x: number, shift_y: number, shift_z: number): void;
26
+ //# sourceMappingURL=v3_grid_patch_edges_uniform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3_grid_patch_edges_uniform.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,oDARW,YAAY,GAAC,UAAU,SACvB,MAAM,SACN,MAAM,SACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,QAehB"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Fill the edges exposed by {@link v3_grid_shift_in_place} (with the same
3
+ * `(shift_x, shift_y, shift_z)`) by replicating the adjacent valid column / row /
4
+ * slice — zero-gradient Neumann extrapolation, equivalent to "the field is locally
5
+ * uniform near the boundary".
6
+ *
7
+ * Axes are patched independently in x → y → z order. Corner cells (where two or
8
+ * three axis-edges meet) are written by every axis they belong to; the final value
9
+ * comes from the last axis, which sees the previously-patched cells as already-valid
10
+ * neighbours.
11
+ *
12
+ * No-ops:
13
+ * - All shifts zero → nothing to patch.
14
+ * - `|shift| >= res` on any axis → the shift primitive already zero-filled the
15
+ * buffer; nothing to replicate from.
16
+ *
17
+ * @param {Float32Array|Uint8Array} buffer
18
+ * @param {number} res_x
19
+ * @param {number} res_y
20
+ * @param {number} res_z
21
+ * @param {number} shift_x integer; same value passed to v3_grid_shift_in_place
22
+ * @param {number} shift_y integer
23
+ * @param {number} shift_z integer
24
+ */
25
+ export function v3_grid_patch_edges_uniform(buffer, res_x, res_y, res_z, shift_x, shift_y, shift_z) {
26
+ if (shift_x === 0 && shift_y === 0 && shift_z === 0) {
27
+ return;
28
+ }
29
+
30
+ if (Math.abs(shift_x) >= res_x || Math.abs(shift_y) >= res_y || Math.abs(shift_z) >= res_z) {
31
+ // Full clear from the shift primitive; no valid neighbour to replicate.
32
+ return;
33
+ }
34
+
35
+ if (shift_x !== 0) patch_x(buffer, res_x, res_y, res_z, shift_x);
36
+ if (shift_y !== 0) patch_y(buffer, res_x, res_y, res_z, shift_y);
37
+ if (shift_z !== 0) patch_z(buffer, res_x, res_y, res_z, shift_z);
38
+ }
39
+
40
+ function patch_x(buf, rx, ry, rz, shift) {
41
+ const slice = rx * ry;
42
+ if (shift > 0) {
43
+ // Exposed: x in [rx - shift, rx). Source: column x = rx - shift - 1.
44
+ const src_x = rx - shift - 1;
45
+ const first_exposed = rx - shift;
46
+ for (let z = 0; z < rz; z++) {
47
+ const z_off = z * slice;
48
+ for (let y = 0; y < ry; y++) {
49
+ const row = z_off + y * rx;
50
+ const src_value = buf[row + src_x];
51
+ for (let x = first_exposed; x < rx; x++) {
52
+ buf[row + x] = src_value;
53
+ }
54
+ }
55
+ }
56
+ } else {
57
+ const n = -shift;
58
+ // Exposed: x in [0, n). Source: column x = n.
59
+ for (let z = 0; z < rz; z++) {
60
+ const z_off = z * slice;
61
+ for (let y = 0; y < ry; y++) {
62
+ const row = z_off + y * rx;
63
+ const src_value = buf[row + n];
64
+ for (let x = 0; x < n; x++) {
65
+ buf[row + x] = src_value;
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+
72
+ function patch_y(buf, rx, ry, rz, shift) {
73
+ const slice = rx * ry;
74
+ if (shift > 0) {
75
+ // Exposed: y in [ry - shift, ry). Source: row y = ry - shift - 1.
76
+ const src_y = ry - shift - 1;
77
+ const first_exposed = ry - shift;
78
+ for (let z = 0; z < rz; z++) {
79
+ const z_off = z * slice;
80
+ const src_row = z_off + src_y * rx;
81
+ for (let y = first_exposed; y < ry; y++) {
82
+ buf.copyWithin(z_off + y * rx, src_row, src_row + rx);
83
+ }
84
+ }
85
+ } else {
86
+ const n = -shift;
87
+ for (let z = 0; z < rz; z++) {
88
+ const z_off = z * slice;
89
+ const src_row = z_off + n * rx;
90
+ for (let y = 0; y < n; y++) {
91
+ buf.copyWithin(z_off + y * rx, src_row, src_row + rx);
92
+ }
93
+ }
94
+ }
95
+ }
96
+
97
+ function patch_z(buf, rx, ry, rz, shift) {
98
+ const slice = rx * ry;
99
+ if (shift > 0) {
100
+ // Exposed: z in [rz - shift, rz). Source: slice z = rz - shift - 1.
101
+ const src_slice_start = (rz - shift - 1) * slice;
102
+ const first_exposed = rz - shift;
103
+ for (let z = first_exposed; z < rz; z++) {
104
+ buf.copyWithin(z * slice, src_slice_start, src_slice_start + slice);
105
+ }
106
+ } else {
107
+ const n = -shift;
108
+ const src_slice_start = n * slice;
109
+ for (let z = 0; z < n; z++) {
110
+ buf.copyWithin(z * slice, src_slice_start, src_slice_start + slice);
111
+ }
112
+ }
113
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Shifts `buffer` contents in place by `(shift_x, shift_y, shift_z)` grid cells.
3
+ *
4
+ * Direction convention: the cell at position `(i, j, k)` after the shift contains the
5
+ * value previously at `(i + shift_x, j + shift_y, k + shift_z)`. Equivalent semantics:
6
+ * the grid moved by `(shift_x, shift_y, shift_z)` cells in world space and the fluid
7
+ * data (which is anchored to world space, not to the moving grid) follows.
8
+ *
9
+ * Cells whose source would have been outside the grid are NOT touched here — they
10
+ * still contain whatever stale data the underlying axis copy left behind. Patch them
11
+ * separately via {@link v3_grid_patch_edges_uniform}, which knows the same
12
+ * `(shift_x, shift_y, shift_z)` and writes a Neumann zero-gradient extrapolation into
13
+ * the exposed cells.
14
+ *
15
+ * If `|shift|` on any axis is `>= res` on that axis, no valid source data remains
16
+ * after the shift. The buffer is zero-filled and the patcher will leave it that way.
17
+ *
18
+ * Each axis is shifted independently via `TypedArray.copyWithin`, which handles
19
+ * overlapping source/destination correctly (`memmove`-like semantics).
20
+ *
21
+ * @param {Float32Array|Uint8Array} buffer
22
+ * @param {number} res_x
23
+ * @param {number} res_y
24
+ * @param {number} res_z
25
+ * @param {number} shift_x integer
26
+ * @param {number} shift_y integer
27
+ * @param {number} shift_z integer
28
+ */
29
+ export function v3_grid_shift_in_place(buffer: Float32Array | Uint8Array, res_x: number, res_y: number, res_z: number, shift_x: number, shift_y: number, shift_z: number): void;
30
+ //# sourceMappingURL=v3_grid_shift_in_place.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3_grid_shift_in_place.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/fluid/solver/v3_grid_shift_in_place.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,+CARW,YAAY,GAAC,UAAU,SACvB,MAAM,SACN,MAAM,SACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,QAkChB"}
@@ -0,0 +1,107 @@
1
+ import { assert } from "../../../../core/assert.js";
2
+
3
+ /**
4
+ * Shifts `buffer` contents in place by `(shift_x, shift_y, shift_z)` grid cells.
5
+ *
6
+ * Direction convention: the cell at position `(i, j, k)` after the shift contains the
7
+ * value previously at `(i + shift_x, j + shift_y, k + shift_z)`. Equivalent semantics:
8
+ * the grid moved by `(shift_x, shift_y, shift_z)` cells in world space and the fluid
9
+ * data (which is anchored to world space, not to the moving grid) follows.
10
+ *
11
+ * Cells whose source would have been outside the grid are NOT touched here — they
12
+ * still contain whatever stale data the underlying axis copy left behind. Patch them
13
+ * separately via {@link v3_grid_patch_edges_uniform}, which knows the same
14
+ * `(shift_x, shift_y, shift_z)` and writes a Neumann zero-gradient extrapolation into
15
+ * the exposed cells.
16
+ *
17
+ * If `|shift|` on any axis is `>= res` on that axis, no valid source data remains
18
+ * after the shift. The buffer is zero-filled and the patcher will leave it that way.
19
+ *
20
+ * Each axis is shifted independently via `TypedArray.copyWithin`, which handles
21
+ * overlapping source/destination correctly (`memmove`-like semantics).
22
+ *
23
+ * @param {Float32Array|Uint8Array} buffer
24
+ * @param {number} res_x
25
+ * @param {number} res_y
26
+ * @param {number} res_z
27
+ * @param {number} shift_x integer
28
+ * @param {number} shift_y integer
29
+ * @param {number} shift_z integer
30
+ */
31
+ export function v3_grid_shift_in_place(buffer, res_x, res_y, res_z, shift_x, shift_y, shift_z) {
32
+ assert.isInteger(shift_x, "shift_x");
33
+ assert.isInteger(shift_y, "shift_y");
34
+ assert.isInteger(shift_z, "shift_z");
35
+
36
+ if (shift_x === 0 && shift_y === 0 && shift_z === 0) {
37
+ return;
38
+ }
39
+
40
+ const cell_count = res_x * res_y * res_z;
41
+ assert.greaterThanOrEqual(buffer.length, cell_count, "buffer covers grid");
42
+
43
+ // Any axis shift exceeding the grid leaves no valid source data on that axis,
44
+ // and therefore on the whole buffer (every cell's source maps outside).
45
+ if (Math.abs(shift_x) >= res_x || Math.abs(shift_y) >= res_y || Math.abs(shift_z) >= res_z) {
46
+ for (let i = 0; i < cell_count; i++) {
47
+ buffer[i] = 0;
48
+ }
49
+ return;
50
+ }
51
+
52
+ const slice = res_x * res_y;
53
+
54
+ if (shift_x !== 0) {
55
+ shift_axis_x(buffer, res_x, res_y, res_z, shift_x, slice);
56
+ }
57
+ if (shift_y !== 0) {
58
+ shift_axis_y(buffer, res_x, res_y, res_z, shift_y, slice);
59
+ }
60
+ if (shift_z !== 0) {
61
+ shift_axis_z(buffer, res_x, res_y, res_z, shift_z, slice);
62
+ }
63
+ }
64
+
65
+ function shift_axis_x(buf, rx, ry, rz, shift, slice) {
66
+ const n = Math.abs(shift);
67
+ for (let z = 0; z < rz; z++) {
68
+ const z_off = z * slice;
69
+ for (let y = 0; y < ry; y++) {
70
+ const row = z_off + y * rx;
71
+ if (shift > 0) {
72
+ // dst x in [0, rx - n) ← src x in [n, rx).
73
+ buf.copyWithin(row, row + n, row + rx);
74
+ } else {
75
+ // dst x in [n, rx) ← src x in [0, rx - n).
76
+ buf.copyWithin(row + n, row, row + rx - n);
77
+ }
78
+ }
79
+ }
80
+ }
81
+
82
+ function shift_axis_y(buf, rx, ry, rz, shift, slice) {
83
+ const n = Math.abs(shift);
84
+ const row_size = rx;
85
+ for (let z = 0; z < rz; z++) {
86
+ const z_off = z * slice;
87
+ if (shift > 0) {
88
+ // dst y in [0, ry - n) ← src y in [n, ry).
89
+ buf.copyWithin(z_off, z_off + n * row_size, z_off + ry * row_size);
90
+ } else {
91
+ // dst y in [n, ry) ← src y in [0, ry - n).
92
+ buf.copyWithin(z_off + n * row_size, z_off, z_off + (ry - n) * row_size);
93
+ }
94
+ }
95
+ }
96
+
97
+ function shift_axis_z(buf, rx, ry, rz, shift, slice) {
98
+ const n = Math.abs(shift);
99
+ const total = rx * ry * rz;
100
+ if (shift > 0) {
101
+ // dst z in [0, rz - n) ← src z in [n, rz).
102
+ buf.copyWithin(0, n * slice, total);
103
+ } else {
104
+ // dst z in [n, rz) ← src z in [0, rz - n).
105
+ buf.copyWithin(n * slice, 0, total - n * slice);
106
+ }
107
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Solve the pressure Poisson equation `∇²p = div(v)` by red-black Successive
3
+ * Over-Relaxation (SOR), gated by a pre-baked per-cell neighbour mask.
4
+ *
5
+ * Per cell, the update is:
6
+ *
7
+ * p_jacobi(c) = ( sum_of_fluid_neighbour_pressures - div(c) ) / count
8
+ * p(c) = (1 - ω) * p(c) + ω * p_jacobi(c)
9
+ *
10
+ * "Which neighbours count as fluid" is determined entirely by `neighbour_mask`,
11
+ * a Uint8Array allocated and populated by {@link FluidField} via
12
+ * {@link FluidField.recomputeSolidNeighbourMask}. The encoding is:
13
+ *
14
+ * bit 0 (= 1) : -x neighbour is fluid
15
+ * bit 1 (= 2) : +x neighbour is fluid
16
+ * bit 2 (= 4) : -y neighbour is fluid
17
+ * bit 3 (= 8) : +y neighbour is fluid
18
+ * bit 4 (= 16) : -z neighbour is fluid
19
+ * bit 5 (= 32) : +z neighbour is fluid
20
+ *
21
+ * Solid cells encode as `mask = 0`, so the inner loop's `mask === 0 ? skip` covers
22
+ * both self-solid AND fluid-with-no-fluid-neighbours in one comparison. This
23
+ * eliminates six boundary checks plus six solid-neighbour checks per cell per
24
+ * iteration, replacing them with a single mask read and six bit-tests on a
25
+ * register-resident value. Boundary handling (cells at x=0, x=last, etc.) is
26
+ * implicit — the recompute step writes 0 into the boundary-facing bit, so the
27
+ * SOR loop never reads out-of-range memory.
28
+ *
29
+ * Cells are visited in two passes per iteration: first "red" (`(x+y+z) % 2 === 0`)
30
+ * then "black". Adjacent cells have opposite colour, so each pass reads only
31
+ * cells of the other colour and writes are independent — same in-place red-black
32
+ * scheme as the un-masked variant.
33
+ *
34
+ * @param {Float32Array|Float16Array} pressure Mutated in place. Pre-fill with 0
35
+ * or with the previous step's solution to warm-start.
36
+ * @param {Float32Array|Float16Array} divergence From
37
+ * {@link v3_grid_compute_divergence}. Same dtype as pressure.
38
+ * @param {number} res_x
39
+ * @param {number} res_y
40
+ * @param {number} res_z
41
+ * @param {number} iterations Number of red-black sweeps.
42
+ * @param {number} omega SOR relaxation factor in (0, 2). Near-optimal values
43
+ * come from {@link optimal_sor_omega}.
44
+ * @param {Uint8Array} neighbour_mask Length ≥ res_x*res_y*res_z. Each byte
45
+ * encodes the fluid-neighbour bitmask (see above). MUST be recomputed
46
+ * whenever the underlying solid mask changes.
47
+ */
48
+ export function v3_grid_solve_pressure(pressure: Float32Array | Float16Array, divergence: Float32Array | Float16Array, res_x: number, res_y: number, res_z: number, iterations: number, omega: number, neighbour_mask: Uint8Array): void;
49
+ //# sourceMappingURL=v3_grid_solve_pressure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v3_grid_solve_pressure.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/fluid/solver/v3_grid_solve_pressure.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,iDAdW,YAAY,eAAa,cAEzB,YAAY,eAAa,SAEzB,MAAM,SACN,MAAM,SACN,MAAM,cACN,MAAM,SACN,MAAM,kBAEN,UAAU,QA+DpB"}